Commit b119aba8 authored by Frank Bergmann's avatar Frank Bergmann

Initial import

parents
Pipeline #82 failed with stages
<?xml version="1.0"?>
<!-- Generated by the OpenACS Package Manager -->
<package key="acs-mail-lite" url="http://openacs.org/repository/apm/packages/acs-mail-lite" type="apm_service">
<package-name>Mail Services Lite</package-name>
<pretty-plural>Mail Services Lite</pretty-plural>
<initial-install-p>f</initial-install-p>
<singleton-p>t</singleton-p>
<version name="0.7a" url="http://openacs.org/repository/download/apm/acs-mail-lite-0.7a.apm">
<owner url="mailto:eric@openforce.biz">Eric Lorenzo</owner>
<owner url="mailto:timo@studio-k4.de">Timo Hentschel</owner>
<summary>Simplified reliable email transmission with bounce management.</summary>
<release-date>2004-01-14</release-date>
<description format="text/html">This package provides a simple ns_sendmail-like interface for sending messages, but queues messages in the database to ensure reliable sending and make sending a message 'transactional'. Prefered over acs-messaging or acs-mail.</description>
<provides url="acs-mail-lite" version="0.7a"/>
<callbacks>
<callback type="before-uninstall" proc="acs_mail_lite::before_uninstall"/>
<callback type="after-install" proc="acs_mail_lite::after_install"/>
</callbacks>
<parameters>
<parameter datatype="string" min_n_values="1" max_n_values="1" name="BounceDomain" description="Email Domain for outgoing messages" section_name="email"/>
<parameter datatype="string" min_n_values="1" max_n_values="1" name="BounceMailDir" description="Location of the maildir location that accepts incoming bounces" section_name="email"/>
<parameter datatype="number" min_n_values="1" max_n_values="1" name="BounceScanQueue" default="120" description="How often (in seconds) to scan for new bounces" section_name="email"/>
<parameter datatype="string" min_n_values="1" max_n_values="1" name="EnvelopePrefix" default="bounce" description="The prefix for sending mail that will be handled by this instance" section_name="email"/>
<parameter datatype="number" min_n_values="1" max_n_values="1" name="MaxBounceCount" default="10" description="Number of bounced emails after resulting in disabling an email-address" section_name="email"/>
<parameter datatype="number" min_n_values="1" max_n_values="1" name="MaxDaysToBounce" default="2" description="Number of days after mail sending a bounce is expected at the very latest" section_name="email"/>
<parameter datatype="number" min_n_values="1" max_n_values="1" name="MaxNotificationCount" default="4" description="Number of times the user will get a notification that his email got disabled in the system" section_name="email"/>
<parameter datatype="string" min_n_values="1" max_n_values="1" name="MMEncodeBin" default="/usr/bin/mmencode" description="Location of mmencode executable." section_name="email"/>
<parameter datatype="number" min_n_values="1" max_n_values="1" name="NotificationInterval" default="7" description="Number of days the users with bouncing email will be notified again on how to reenable the email again" section_name="email"/>
<parameter datatype="string" min_n_values="1" max_n_values="1" name="NotificationSender" default="reminder@openacs.org" description="Sender of the notification email" section_name="email"/>
<parameter datatype="number" min_n_values="1" max_n_values="1" name="send_immediately" default="0" description="Boolean value to say whether new mails should be send out immediately or stored in the db before send out." section_name="email"/>
<parameter datatype="string" min_n_values="1" max_n_values="1" name="SendmailBin" default="/usr/sbin/sendmail" description="Location of sendmail binary on your system (Set to SMTP to use SMTP server)" section_name="email"/>
</parameters>
</version>
</package>
--
-- A simple mail queue
--
-- @author <a href="mailto:eric@openforce.net">eric@openforce.net</a>
-- @version $Id$
--
create sequence acs_mail_lite_id_seq;
create table acs_mail_lite_queue (
message_id integer
constraint acs_mail_lite_queue_pk
primary key,
to_addr varchar(400),
from_addr varchar(200),
subject varchar(200),
body clob,
extra_headers clob,
bcc clob,
package_id integer
constraint acs_mail_lite_queue_pck_fk
references apm_packages,
valid_email_p varchar2(1)
constraint acs_mail_lite_qu_valid_em_p_ck
check (valid_email_p in ('t','f'))
);
create table acs_mail_lite_mail_log (
user_id integer
constraint acs_mail_lite_log_user_id_fk
references users (user_id)
on delete cascade
constraint acs_mail_lite_log_pk
primary key,
last_mail_date date default sysdate
);
create table acs_mail_lite_bounce (
user_id integer
constraint acs_mail_lite_bou_user_id_fk
references users (user_id)
on delete cascade
constraint acs_mail_lite_bou_pk
primary key,
bounce_count integer default 1
);
create table acs_mail_lite_bounce_notif (
user_id integer
constraint acs_mail_li_bou_notif_us_id_fk
references users (user_id)
on delete cascade
constraint acs_mail_lite_notif_pk
primary key,
notification_time date default sysdate,
notification_count integer default 0
);
--
-- A simple mail queue
--
-- @author <a href="mailto:eric@openforce.net">eric@openforce.net</a>
-- @version $Id$
--
drop table acs_mail_lite_queue;
drop sequence acs_mail_lite_id_seq;
alter table acs_mail_lite_queue add (package_id integer constraint acs_mail_lite_queue_pck_fk references apm_packages);
alter table acs_mail_lite_queue add (valid_email_p varchar2(1) constraint acs_mail_lite_qu_valid_em_p_ck check (valid_email_p in ('t','f')));
create table acs_mail_lite_mail_log (
user_id integer
constraint acs_mail_lite_log_user_id_fk
references users (user_id)
on delete cascade
constraint acs_mail_lite_log_pk
primary key,
last_mail_date date default sysdate
);
create table acs_mail_lite_bounce (
user_id integer
constraint acs_mail_lite_bou_user_id_fk
references users (user_id)
on delete cascade
constraint acs_mail_lite_bou_pk
primary key,
bounce_count integer default 1
);
create table acs_mail_lite_bounce_notif (
user_id integer
constraint acs_mail_li_bou_notif_us_id_fk
references users (user_id)
on delete cascade
constraint acs_mail_lite_notif_pk
primary key,
notification_time date default sysdate,
notification_count integer default 0
);
\ No newline at end of file
--
-- A simple mail queue
--
-- @author <a href="mailto:eric@openforce.net">eric@openforce.net</a>
-- @version $Id$
--
create sequence acs_mail_lite_id_seq;
create table acs_mail_lite_queue (
message_id integer
constraint acs_mail_lite_queue_pk
primary key,
to_addr text,
from_addr varchar(200),
subject varchar(200),
body text,
extra_headers text,
bcc text,
package_id integer
constraint acs_mail_lite_queue_pck_fk
references apm_packages,
valid_email_p boolean
);
create table acs_mail_lite_mail_log (
user_id integer
constraint acs_mail_lite_log_user_id_fk
references users (user_id)
on delete cascade
constraint acs_mail_lite_log_pk
primary key,
last_mail_date timestamptz default current_timestamp
);
create table acs_mail_lite_bounce (
user_id integer
constraint acs_mail_lite_bou_user_id_fk
references users (user_id)
on delete cascade
constraint acs_mail_lite_bou_pk
primary key,
bounce_count integer default 1
);
create table acs_mail_lite_bounce_notif (
user_id integer
constraint acs_mail_li_bou_notif_us_id_fk
references users (user_id)
on delete cascade
constraint acs_mail_lite_notif_pk
primary key,
notification_time timestamptz default current_timestamp,
notification_count integer default 0
);
--
-- A simple mail queue
--
-- @author <a href="mailto:eric@openforce.net">eric@openforce.net</a>
-- @version $Id$
--
drop table acs_mail_lite_queue;
drop sequence acs_mail_lite_id_seq;
drop table acs_mail_lite_mail_log;
drop table acs_mail_lite_bounce;
drop table acs_mail_lite_bounce_notif;
\ No newline at end of file
alter table acs_mail_lite_queue add column package_id integer constraint acs_mail_lite_queue_pck_fk references apm_packages;
alter table acs_mail_lite_queue add column valid_email_p boolean;
create table acs_mail_lite_mail_log (
user_id integer
constraint acs_mail_lite_log_user_id_fk
references users (user_id)
on delete cascade
constraint acs_mail_lite_log_pk
primary key,
last_mail_date timestamptz default current_timestamp
);
create table acs_mail_lite_bounce (
user_id integer
constraint acs_mail_lite_bou_user_id_fk
references users (user_id)
on delete cascade
constraint acs_mail_lite_bou_pk
primary key,
bounce_count integer default 1
);
create table acs_mail_lite_bounce_notif (
user_id integer
constraint acs_mail_li_bou_notif_us_id_fk
references users (user_id)
on delete cascade
constraint acs_mail_lite_notif_pk
primary key,
notification_time timestamptz default current_timestamp,
notification_count integer default 0
);
\ No newline at end of file
ad_library {
initialization for acs_mail_lite module
@author Eric Lorenzo (eric@openforce.net)
@creation-date 22 March, 2002
@cvs-id $Id$
}
# Default interval is 1 minute.
ad_schedule_proc -thread t 60 acs_mail_lite::sweeper
# check every few minutes for bounces
ad_schedule_proc -thread t [acs_mail_lite::get_parameter -name BounceScanQueue -default 120] acs_mail_lite::scan_replies
nsv_set acs_mail_lite send_mails_p 0
nsv_set acs_mail_lite check_bounce_p 0
ad_schedule_proc -thread t -schedule_proc ns_schedule_daily [list 0 25] acs_mail_lite::check_bounces
<?xml version="1.0"?>
<queryset>
<rdbms><type>oracle</type><version>8.1.6</version></rdbms>
<fullquery name="acs_mail_lite::check_bounces.send_notification_to_bouncing_email">
<querytext>
insert into acs_mail_lite_bounce_notif
(user_id, notification_count, notification_time)
(select user_id, 0 as notification_count,
trunc(sysdate-1-:notification_interval) as notification_time
from acs_mail_lite_bounce
where bounce_count >= :max_bounce_count)
</querytext>
</fullquery>
<fullquery name="acs_mail_lite::check_bounces.get_recent_bouncing_users">
<querytext>
select u.user_id, u.email, u.first_names || ' ' || u.last_name as name
from cc_users u, acs_mail_lite_bounce_notif n
where u.user_id = n.user_id
and u.email_bouncing_p = 't'
and n.notification_time < sysdate - :notification_interval
and n.notification_count < :max_notification_count
</querytext>
</fullquery>
<fullquery name="acs_mail_lite::check_bounces.log_notication_sending">
<querytext>
update acs_mail_lite_bounce_notif
set notification_time = trunc(sysdate),
notification_count = notification_count + 1
where user_id = :user_id
</querytext>
</fullquery>
<fullquery name="acs_mail_lite::check_bounces.delete_log_if_no_recent_bounce">
<querytext>
delete from acs_mail_lite_bounce
where user_id in (select user_id
from acs_mail_lite_mail_log
where last_mail_date < sysdate - :max_days_to_bounce)
</querytext>
</fullquery>
<fullquery name="acs_mail_lite::send.create_queue_entry">
<querytext>
insert into acs_mail_lite_queue
(message_id, to_addr, from_addr, subject, body, extra_headers, bcc,
package_id, valid_email_p)
values
(acs_mail_lite_id_seq.nextval, :to_addr, :from_addr, :subject, :body,
:eh_list, :bcc, :package_id, decode(:valid_email_p,'1','t','f'))
</querytext>
</fullquery>
<fullquery name="acs_mail_lite::log_mail_sending.record_mail_sent">
<querytext>
update acs_mail_lite_mail_log
set last_mail_date = sysdate
where user_id = :user_id
</querytext>
</fullquery>
<fullquery name="acs_mail_lite::log_mail_sending.insert_log_entry">
<querytext>
insert into acs_mail_lite_mail_log (user_id, last_mail_date)
values (:user_id, sysdate)
</querytext>
</fullquery>
<fullquery name="acs_mail_lite::sweeper.get_queued_messages">
<querytext>
select message_id,
to_addr,
from_addr,
subject,
body,
extra_headers,
bcc,
package_id,
decode(valid_email_p,'t',1,0) as valid_email_p
from acs_mail_lite_queue
</querytext>
</fullquery>
<fullquery name="acs_mail_lite::send_immediately.create_queue_entry">
<querytext>
insert into acs_mail_lite_queue
(message_id, to_addr, from_addr, subject, body, extra_headers, bcc,
package_id, valid_email_p)
values
(acs_mail_lite_id_seq.nextval, :to_addr, :from_addr, :subject, :body,
:extraheaders, :bcc, :package_id, decode(:valid_email_p,'1','t','f'))
</querytext>
</fullquery>
</queryset>
<?xml version="1.0"?>
<queryset>
<rdbms><type>postgresql</type><version>7.1</version></rdbms>
<fullquery name="acs_mail_lite::check_bounces.send_notification_to_bouncing_email">
<querytext>
insert into acs_mail_lite_bounce_notif (user_id, notification_count, notification_time)
select user_id, 0 as notification_count,
date_trunc('day', current_timestamp - to_interval(1 + :notification_interval, 'days'))
as notification_time
from acs_mail_lite_bounce
where bounce_count >= :max_bounce_count
</querytext>
</fullquery>
<fullquery name="acs_mail_lite::check_bounces.get_recent_bouncing_users">
<querytext>
select u.user_id, u.email, u.first_names || ' ' || u.last_name as name
from cc_users u, acs_mail_lite_bounce_notif n
where u.user_id = n.user_id
and u.email_bouncing_p = 't'
and n.notification_time < current_timestamp - to_interval(:notification_interval, 'days')
and n.notification_count < :max_notification_count
</querytext>
</fullquery>
<fullquery name="acs_mail_lite::check_bounces.log_notication_sending">
<querytext>
update acs_mail_lite_bounce_notif
set notification_time = date_trunc('day',current_timestamp),
notification_count = notification_count + 1
where user_id = :user_id
</querytext>
</fullquery>
<fullquery name="acs_mail_lite::check_bounces.delete_log_if_no_recent_bounce">
<querytext>
delete from acs_mail_lite_bounce
where user_id in (select user_id
from acs_mail_lite_mail_log
where last_mail_date < current_timestamp - to_interval(:max_days_to_bounce, 'days'))
</querytext>
</fullquery>
<fullquery name="acs_mail_lite::send.create_queue_entry">
<querytext>
insert into acs_mail_lite_queue
(message_id, to_addr, from_addr, subject, body, extra_headers, bcc, package_id, valid_email_p)
values
(nextval('acs_mail_lite_id_seq'), :to_addr, :from_addr, :subject, :body, :eh_list, :bcc, :package_id,
(case when :valid_email_p = '1' then TRUE else FALSE end))
</querytext>
</fullquery>
<fullquery name="acs_mail_lite::log_mail_sending.record_mail_sent">
<querytext>
update acs_mail_lite_mail_log
set last_mail_date = current_timestamp
where user_id = :user_id
</querytext>
</fullquery>
<fullquery name="acs_mail_lite::log_mail_sending.insert_log_entry">
<querytext>
insert into acs_mail_lite_mail_log (user_id, last_mail_date)
values (:user_id, current_timestamp)
</querytext>
</fullquery>
<fullquery name="acs_mail_lite::sweeper.get_queued_messages">
<querytext>
select message_id,
to_addr,
from_addr,
subject,
body,
extra_headers,
bcc,
package_id,
(case when valid_email_p = TRUE then 1
else 0
end) as valid_email_p
from acs_mail_lite_queue
</querytext>
</fullquery>
<fullquery name="acs_mail_lite::send_immediately.create_queue_entry">
<querytext>
insert into acs_mail_lite_queue
(message_id, to_addr, from_addr, subject, body, extra_headers, bcc,
package_id, valid_email_p)
values
(nextval('acs_mail_lite_id_seq'), :to_addr, :from_addr, :subject, :body,
:extraheaders, :bcc, :package_id,
(case when :valid_email_p = '1' then TRUE
else FALSE end))
</querytext>
</fullquery>
</queryset>
This diff is collapsed.
<?xml version="1.0"?>
<queryset>
<fullquery name="acs_mail_lite::bouncing_email_p.bouncing_p">
<querytext>
select case when email_bouncing_p = 't' then 1 else 0 end
as send_p
from cc_users
where lower(email) = lower(:email)
</querytext>
</fullquery>
<fullquery name="acs_mail_lite::bouncing_user_p.bouncing_p">
<querytext>
select case when email_bouncing_p = 't' then 1 else 0 end
as send_p
from cc_users
where user_id = :user_id
</querytext>
</fullquery>
<fullquery name="acs_mail_lite::log_mail_sending.record_mail_sent">
<querytext>
update acs_mail_lite_mail_log
set last_mail_date = sysdate
where user_id = :user_id
</querytext>
</fullquery>
<fullquery name="acs_mail_lite::log_mail_sending.insert_log_entry">
<querytext>
insert into acs_mail_lite_mail_log (user_id, last_mail_date)
values (:user_id, sysdate)
</querytext>
</fullquery>
<fullquery name="acs_mail_lite::load_mail_dir.record_bounce">
<querytext>
update acs_mail_lite_bounce
set bounce_count = bounce_count + 1
where user_id = :user_id
</querytext>
</fullquery>
<fullquery name="acs_mail_lite::load_mail_dir.insert_bounce">
<querytext>
insert into acs_mail_lite_bounce (user_id, bounce_count)
values (:user_id, 1)
</querytext>
</fullquery>
<fullquery name="acs_mail_lite::check_bounces.delete_log_if_no_recent_bounce">
<querytext>
delete from acs_mail_lite_bounce
where user_id in (select user_id
from acs_mail_lite_mail_log
where last_mail_date < sysdate - :max_days_to_bounce)
</querytext>
</fullquery>
<fullquery name="acs_mail_lite::check_bounces.disable_bouncing_email">
<querytext>
update users
set email_bouncing_p = 't'
where user_id in (select user_id
from acs_mail_lite_bounce
where bounce_count >= :max_bounce_count)
</querytext>
</fullquery>
<fullquery name="acs_mail_lite::check_bounces.delete_bouncing_users_from_log">
<querytext>
delete from acs_mail_lite_bounce
where bounce_count >= :max_bounce_count
</querytext>
</fullquery>
<fullquery name="acs_mail_lite::get_address_array.get_user_name_and_id">
<querytext>
select user_id, first_names || ' ' || last_name as user_name
from cc_users
where email = :email
</querytext>
</fullquery>
<fullquery name="acs_mail_lite::sweeper.delete_queue_entry">
<querytext>
delete
from acs_mail_lite_queue
where message_id = :message_id
</querytext>
</fullquery>
</queryset>
<html>
<head><title>User Documentation for ACS Mail Lite</title></head>
<body>
<h2>User Documentation for ACS Mail Lite</h2>
Acs Mail Lite handles sending of email via sendmail or smtp
and includes a bounce management system for invalid email
accounts.
<p>
When called to send a mail, the mail will either get sent immediately
or placed in an outgoing queue (changeable via parameter) which
will be processed every few minutes.
<p>
ACS Mail Lite uses either sendmail (you have to provide the
location of the binary as a parameter) or SMTP to send the mail.
If the sending fails, the mail will be placed in the outgoing queue
again and be given another try a few minutes later when processing
the queue again.
<p>
Each email contains an X-Envelope-From adress constructed as
follows:<br>
The adress starts with "bounce" (can be changed by a parameter)
followed by the user_id, a hashkey and the package_id of the
package instance that sent the email, separated by "-". The
domain name of this adress can be changed with a parameter.
<p>
The system checks every 2 minutes (configurable) in a certain
maildirectory (configurable) for newly bounced emails, so the
mailsystem will have to place every mail to an address beginning
with "bounce" (or whatever the appropriate parameter says) in that
directory. The system then processes each of the bounced emails,
strips out the message_id and verifies the hashkey in the bounce-address.
After that the package-key of the package sending the original mail
is found out by using the package_id provided in the bounce
adress. With that, the system then tries to invoke a callback
procedure via a service contract if one is registered for that
particular package-key. This enables each package to deal with
bouncing mails on their own - probably logging this in special tables.
ACS Mail Lite then logs the event of a bounced mail of that
user.
<p>
Every day a procedure is run that checks if an email account
has to be disabled from receiving any more mail. This is done
the following way:
<ul>
<li>If a user received his last mail X days ago without any further
bounced mail then his bounce-record gets deleted since it can
be assumed that his email account is working again and no longer
refusing emails. This value can be changed with the parameter
"MaxDaysToBounce".</li>
<li>If more then Y emails were returned by a particular user then
his email account gets disabled from receiving any more mails
from the system by setting the email_bouncing_p flag to t. This
value can be changed with the parameter "MaxBounceCount".</li>
<li>To notify users that they will not receive any more mails and to
tell them how to reenable the email account in the system again,
a notification email gets sent every 7 days (configurable)
up to 4 times (configurable) that contains a link to reenable
the email account.</li>
</ul>
To use this system here is a quick guide how to do it with postfix.
<ul>
<li>Edit /etc/postfix/main.cf
<ul>
<li>Set "recipient_delimiter" to " - "
<li>Set "home_mailbox" to "Maildir/"
<li>Make sure that /etc/postfix/aliases is hashed for the alias database
</ul>
<li>Edit /etc/postfix/aliases. Redirect all mail to "bounce" (if you leave the parameter as it was) to "nsadmin" (in case you only run one server).
</ul>
In case of multiple services on one system, create a bounce email for each of them (e.g. changeing "bounce" to "bounce_service1") and create a new user that runs the aolserver process for each of them. You do not want to have service1 deal with bounces for service2.
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment