Commit d7e69903 authored by Malte Sussdorff's avatar Malte Sussdorff

- Malte

parent cd19d3fa
Pipeline #83 failed with stages
......@@ -7,32 +7,41 @@
<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">
<version name="5.4.0d2" url="http://openacs.org/repository/download/apm/acs-mail-lite-5.4.0d2.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>
<release-date>2005-10-19</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>
<maturity>2</maturity>
<provides url="acs-mail-lite" version="0.7a"/>
<provides url="acs-mail-lite" version="5.4.0d2"/>
<requires url="acs-tcl" version="5.3.0d2"/>
<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="string" min_n_values="1" max_n_values="1" name="FixedSenderEmail" description="Email addres that will be always the email stored in the sender. Default is empty" section_name="email"/>
<parameter datatype="string" min_n_values="1" max_n_values="1" name="FixedFont" description="Font definition (after the font tag) that will always be wrapped around HTML e-mail. Example: face=Verdana size=2. Default is empty" 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="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="NotificationSender" description="Sender of the notification email" 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"/>
<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="number" min_n_values="1" max_n_values="1" name="FolderID" default="" description="Folder ID of a folder in the content repository that contains files that can be included using checkboxes in each e-mail send out of the system. This effects /lib/email" section_name="email"/>
<parameter datatype="string" min_n_values="1" max_n_values="1" name="SMTPHost" default="localhost" description="SMTP Host to be used for sending emails" section_name="SMTP"/>
<parameter datatype="number" min_n_values="1" max_n_values="1" name="SMTPPort" default="25" description="SMTP Port to be used for sending emails" section_name="SMTP"/>
<parameter datatype="number" min_n_values="1" max_n_values="1" name="SMTPTimeout" default="60" description="SMTP Timeout. Waiting time until we give up with the mailserver." section_name="SMTP"/>
<parameter datatype="string" min_n_values="1" max_n_values="1" name="SMTPUser" default="" description="SMTP User to be used for sending emails" section_name="SMTP"/>
<parameter datatype="string" min_n_values="1" max_n_values="1" name="SMTPPassword" default="" description="SMTP Password to be used for sending emails" section_name="SMTP"/>
</parameters>
</version>
......
<?xml version="1.0" encoding="ISO-8859-1"?>
<message_catalog package_key="acs-mail-lite" package_version="1.1" locale="ca_ES" charset="ISO-8859-1">
<msg key="Associated_files">Fitxers associats:</msg>
<msg key="CC">CC</msg>
<msg key="cc_help">Envia'n cpia a diverses adreces separades per &amp;quot;;&amp;quot;</msg>
<msg key="check_uncheck">Selecciona/Deselecciona</msg>
<msg key="lt_there_was_an_error_processing">S'ha produt un error en processar aquesta petici.</msg>
<msg key="Message">Missatge</msg>
<msg key="Recipients">Destinataris</msg>
<msg key="Send">Envia</msg>
<msg key="Subject">Assumpte</msg>
<msg key="Untitled">Sense ttol</msg>
<msg key="Upload_file">Carrega arxiu</msg>
<msg key="Your_message_was_sent_to">El missatge s'ha enviat a: &amp;amp;lt;strong&amp;amp;gt;%recipients%&amp;amp;lt;/strong&amp;amp;gt;</msg>
</message_catalog>
<?xml version="1.0" encoding="ISO-8859-1"?>
<message_catalog package_key="acs-mail-lite" package_version="1.3b5" locale="de_DE" charset="ISO-8859-1">
<msg key="Associated_files">Verknpfte Dateien:</msg>
<msg key="CC">CC</msg>
<msg key="cc_help">Liste von E-Mail Adressen durch &quot;;&quot; getrennt an die eine Kopie der E-Mail geschickt werden soll.</msg>
<msg key="check_uncheck">Alle/Keine auswhlen</msg>
<msg key="lt_there_was_an_error_processing">Es gab einen Fehler bei der Verarbeitung Ihrer Anfrage</msg>
<msg key="Message">Nachricht</msg>
<msg key="Queue_server">Serverproze</msg>
<msg key="Queueing_time">Queue-Zeitpunkt</msg>
<msg key="Recipients">Empfnger</msg>
<msg key="Send">Senden</msg>
<msg key="Sender">Absender</msg>
<msg key="Subject">Betreff</msg>
<msg key="Untitled">Unbenannt</msg>
<msg key="Upload_file">Datei hinzufgen</msg>
<msg key="Your_message_was_sent_to">Ihre Nachricht wurde an die folgende Empfnger geschickt: %recipients%</msg>
</message_catalog>
<?xml version="1.0" encoding="ISO-8859-1"?>
<message_catalog package_key="acs-mail-lite" package_version="5.4.0d1" locale="en_US" charset="ISO-8859-1">
<msg key="Associated_files">Associated Files:</msg>
<msg key="BCC">BCC</msg>
<msg key="Bounce_disabled">Bouncing recorded as disabled. You will receive E-Mails again.</msg>
<msg key="Bouncing_users">Bouncing users</msg>
<msg key="CC">CC</msg>
<msg key="cc_help">Send copy to multiple addresses separated by &quot;;&quot;</msg>
<msg key="check_uncheck">Check/Uncheck</msg>
<msg key="lt_there_was_an_error_processing">There was an error processing this request.</msg>
<msg key="Message">Message</msg>
<msg key="Queue_server">Queue server</msg>
<msg key="Queueing_time">Queueing time</msg>
<msg key="Recipients">Recipients</msg>
<msg key="Send">Send</msg>
<msg key="Sender">Sender</msg>
<msg key="Subject">Subject</msg>
<msg key="Unbounce">Unbounce</msg>
<msg key="Untitled">Untitled</msg>
<msg key="Upload_file">Upload File</msg>
<msg key="Your_message_was_sent_to">Your message was sent to: &amp;lt;strong&amp;gt;%recipients%&amp;lt;/strong&amp;gt;</msg>
</message_catalog>
<?xml version="1.0" encoding="ISO-8859-1"?>
<message_catalog package_key="acs-mail-lite" package_version="5.3.0" locale="es_ES" charset="ISO-8859-1">
<msg key="Associated_files">Archivos asociados:</msg>
<msg key="CC">CC</msg>
<msg key="cc_help">Enviar copia a varias direcciones separadas por &quot;;&quot;</msg>
<msg key="check_uncheck">Seleccionar/deseleccionar</msg>
<msg key="lt_there_was_an_error_processing">Ocurri un error al procesar su peticin.</msg>
<msg key="Message">Mensaje</msg>
<msg key="Recipients">Destinatarios</msg>
<msg key="Send">Enviar</msg>
<msg key="Subject">Asunto</msg>
<msg key="Untitled">Sin ttulo</msg>
<msg key="Upload_file">Subir Archivo</msg>
<msg key="Your_message_was_sent_to">Su mensaje ha sido enviado a: &lt;strong&gt;%recipients%&lt;/strong&gt;</msg>
</message_catalog>
<?xml version="1.0" encoding="ISO-8859-1"?>
<message_catalog package_key="acs-mail-lite" package_version="1.1" locale="gl_ES" charset="ISO-8859-1">
<msg key="Associated_files">Arquivos asociados:</msg>
<msg key="CC">CC</msg>
<msg key="cc_help">Enviar copia a varias direccins separadas por &amp;quot;;&amp;quot;</msg>
<msg key="check_uncheck">Seleccionar/deseleccionar</msg>
<msg key="lt_there_was_an_error_processing">Ocorreu un erro procesar a sa peticin</msg>
<msg key="Message">Mensaxe</msg>
<msg key="Recipients">Destinatarios</msg>
<msg key="Send">Enviar</msg>
<msg key="Subject">Asunto</msg>
<msg key="Untitled">Sin ttulo</msg>
<msg key="Upload_file">Subir Arquivo</msg>
<msg key="Your_message_was_sent_to">A sa mensaxe foi enviada a:
&lt;strong&gt;%recipients%&lt;/strong&gt;</msg>
</message_catalog>
<?xml version="1.0" encoding="ISO-8859-1"?>
<message_catalog package_key="acs-mail-lite" package_version="1.1" locale="nl_NL" charset="ISO-8859-1">
<msg key="Associated_files">Verbintenis met de bestanden:</msg>
<msg key="CC">CC</msg>
<msg key="cc_help">Stuur kopie aan meerdere adressen gescheiden door &quot;;&quot;</msg>
<msg key="check_uncheck">Aanvinken/Afvinken</msg>
<msg key="lt_there_was_an_error_processing">Er is een fout opgetreden tijdens het verwerken van dit verzoek.</msg>
<msg key="Message">Bericht</msg>
<msg key="Recipients">Ontvangers</msg>
<msg key="Send">Verstuur</msg>
<msg key="Subject">Onderwerp</msg>
<msg key="Untitled">Naamloos</msg>
<msg key="Upload_file">Bestand opladen</msg>
<msg key="Your_message_was_sent_to">Uw bericht is verstuurd aan &lt;strong&gt;%recipients%&lt;/strong&gt;</msg>
</message_catalog>
<?xml version="1.0" encoding="ISO-8859-1"?>
<message_catalog package_key="acs-mail-lite" package_version="1.1" locale="nl_ZA" charset="ISO-8859-1">
<msg key="Associated_files">Verbintenis met die lers:</msg>
<msg key="CC">CC</msg>
<msg key="cc_help">Stuur kopie aan meerdere adresse geskeide deur &quot;;&quot;</msg>
<msg key="check_uncheck">Vink aan/Vink af</msg>
<msg key="lt_there_was_an_error_processing">Daar het 'n fout opgetree tydens verwerking van hierdie versoek.</msg>
<msg key="Message">Berig</msg>
<msg key="Recipients">Ontvangers</msg>
<msg key="Send">Verstuur</msg>
<msg key="Subject">Onderwerp</msg>
<msg key="Untitled">Naamloos</msg>
<msg key="Upload_file">Laai ler</msg>
<msg key="Your_message_was_sent_to">U berig is verstuur aan &lt;string&gt;%recipients%&lt;/strong&gt;</msg>
</message_catalog>
<?xml version="1.0" encoding="utf-8"?>
<message_catalog package_key="acs-mail-lite" package_version="1.1" locale="pl_PL" charset="utf-8">
<msg key="Associated_files">Powiązane Pliki:</msg>
<msg key="CC">CC</msg>
<msg key="cc_help">Wyślij kopie pod wiele adresów rozdzielając je &quot;;&quot;</msg>
<msg key="check_uncheck">Zaznacz/Odznacz</msg>
<msg key="lt_there_was_an_error_processing">Wystąpił błąd.</msg>
<msg key="Message">Komunikat</msg>
<msg key="Recipients">Adresaci</msg>
<msg key="Send">Wyślij</msg>
<msg key="Subject">Temat</msg>
<msg key="Untitled">Bez Tytułu</msg>
<msg key="Upload_file">Wgraj Plik</msg>
<msg key="Your_message_was_sent_to">Twój komunikat wysłano do: &amp;lt;strong&amp;gt;%recipients%&amp;lt;/strong&amp;gt;</msg>
</message_catalog>
<?xml version="1.0" encoding="ISO-8859-1"?>
<message_catalog package_key="acs-mail-lite" package_version="1.1" locale="pt_BR" charset="ISO-8859-1">
<msg key="Associated_files">Arquivos Associados:</msg>
<msg key="CC">CC</msg>
<msg key="cc_help">Enviar cpia para mltiplos endereos de email separados por &quot;;&quot;</msg>
<msg key="check_uncheck">Marcar/Desmarcar</msg>
<msg key="lt_there_was_an_error_processing">Ocorreu um erro ao processar esta solicitao.</msg>
<msg key="Message">Mensagem</msg>
<msg key="Recipients">Destinatrios</msg>
<msg key="Send">Enviar</msg>
<msg key="Subject">Assunto</msg>
<msg key="Untitled">Sem ttulo</msg>
<msg key="Upload_file">Anexar Arquivo</msg>
<msg key="Your_message_was_sent_to">Sua mensagem foi enviada para: &amp;lt;strong&amp;gt;%recipients%&amp;lt;/strong&amp;gt;</msg>
</message_catalog>
<SCRIPT LANGUAGE = "JavaScript">
<!--
function check_uncheck_boxes(checkP){
for ( i=0 ; i < document.email.to.length; i++) {
document.email.to[i].checked = checkP;
}
}
-->
</SCRIPT>
<formtemplate id="email"></formtemplate>
This diff is collapsed.
<?xml version="1.0"?>
<queryset>
<fullquery name="get_file_title">
<querytext>
select
title
from
cr_revisions
where
revision_id = :file
</querytext>
</fullquery>
</queryset>
\ No newline at end of file
<listtemplate name="get_all_complex_queued_messages"></listtemplate>
# 2006/11/17 created (nfl)
template::list::create \
-name get_all_complex_queued_messages \
-selected_format normal \
-multirow messages \
-elements {
creation_date { label "[_ acs-mail-lite.Queueing_time]" }
from_addr { label "[_ acs-mail-lite.Sender]" }
to_addr { label "[_ acs-mail-lite.Recipients]" }
subject { label "[_ acs-mail-lite.Subject]" }
locking_server { label "[_ acs-mail-lite.Queue_server]" }
}
db_multirow messages get_all_complex_queued_messages {}
<?xml version="1.0"?>
<queryset>
<fullquery name="get_all_complex_queued_messages">
<querytext>
select
id,
creation_date,
locking_server,
to_party_ids,
cc_party_ids,
bcc_party_ids,
to_group_ids,
cc_group_ids,
bcc_group_ids,
to_addr,
cc_addr,
bcc_addr,
from_addr,
subject,
body,
package_id,
files,
file_ids,
folder_ids,
mime_type,
object_id,
(case when single_email_p = TRUE then 1 else 0 end) as single_email_p,
(case when no_callback_p = TRUE then 1 else 0 end) as no_callback_p,
extraheaders,
(case when alternative_part_p = TRUE then 1 else 0 end) as alternative_part_p,
(case when use_sender_p = TRUE then 1 else 0 end) as use_sender_p
from acs_mail_lite_complex_queue
order by creation_date
</querytext>
</fullquery>
</queryset>
......@@ -26,9 +26,9 @@ create table acs_mail_lite_queue (
);
create table acs_mail_lite_mail_log (
user_id integer
party_id integer
constraint acs_mail_lite_log_user_id_fk
references users (user_id)
references parties (party_id)
on delete cascade
constraint acs_mail_lite_log_pk
primary key,
......@@ -37,9 +37,9 @@ create table acs_mail_lite_mail_log (
create table acs_mail_lite_bounce (
user_id integer
party_id integer
constraint acs_mail_lite_bou_user_id_fk
references users (user_id)
references parties (party_id)
on delete cascade
constraint acs_mail_lite_bou_pk
primary key,
......@@ -48,12 +48,53 @@ create table acs_mail_lite_bounce (
create table acs_mail_lite_bounce_notif (
user_id integer
party_id integer
constraint acs_mail_li_bou_notif_us_id_fk
references users (user_id)
references parties (party_id)
on delete cascade
constraint acs_mail_lite_notif_pk
primary key,
notification_time date default sysdate,
notification_count integer default 0
);
CREATE TABLE acs_mail_lite_complex_queue (
id integer
constraint acs_mail_lite_complex_queue_pk
PRIMARY KEY,
creation_date text,
locking_server text,
to_party_ids varchar(4000),
cc_party_ids varchar(4000),
bcc_party_ids varchar(4000),
to_group_ids varchar(4000),
cc_group_ids varchar(4000),
bcc_group_ids varchar(4000),
to_addr clob,
cc_addr clob,
bcc_addr clob,
from_addr varchar(400),
reply_to varchar(400),
subject varchar(4000),
body clob,
package_id integer,
files varchar(4000),
file_ids varchar(4000),
folder_ids varchar(4000),
mime_type varchar(200),
object_id integer,
single_email_p varchar2(1)
constraint acs_mail_lite_co_qu_single_em_p_ck
check (valid_email_p in ('t','f')),
no_callback_p varchar2(1)
constraint acs_mail_lite_co_qu_no_callb_p_ck
check (valid_email_p in ('t','f')),
extraheaders clob,
alternative_part_p varchar2(1)
constraint acs_mail_lite_co_qu_alt_part_p_ck
check (valid_email_p in ('t','f')),
use_sender_p varchar2(1)
constraint acs_mail_lite_co_qu_use_sender_p_ck
check (valid_email_p in ('t','f'))
);
......@@ -7,3 +7,7 @@
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;
drop TABLE acs_mail_lite_complex_queue;
\ No newline at end of file
-- Make sure that emails are going to parties not to users and therefore logging is for parties, not for users.
alter table acs_mail_lite_mail_log add column party_id integer references parties(party_id);
update acs_mail_lite_mail_log set party_id = user_id;
alter table acs_mail_lite_mail_log drop column user_id;
alter table acs_mail_lite_bounce add column party_id integer references parties(party_id);
update acs_mail_lite_bounce set party_id = user_id;
alter table acs_mail_lite_bounce drop column user_id;
\ No newline at end of file
-- 2006/11/17 cognovis/nfl
--
-- Name: acs_mail_lite_complex_queue; Type: TABLE; Schema: public; Owner: cognovis; Tablespace:
--
CREATE TABLE acs_mail_lite_complex_queue (
id integer
constraint acs_mail_lite_complex_queue_pk
PRIMARY KEY,
creation_date text,
locking_server text,
to_party_ids varchar(4000),
cc_party_ids varchar(4000),
bcc_party_ids varchar(4000),
to_group_ids varchar(4000),
cc_group_ids varchar(4000),
bcc_group_ids varchar(4000),
to_addr clob,
cc_addr clob,
bcc_addr clob,
from_addr varchar(400),
reply_to varchar(400),
subject varchar(4000),
body clob,
package_id integer,
files varchar(4000),
file_ids varchar(4000),
folder_ids varchar(4000),
mime_type varchar(200),
object_id integer,
single_email_p varchar2(1)
constraint acs_mail_lite_co_qu_single_em_p_ck
check (valid_email_p in ('t','f')),
no_callback_p varchar2(1)
constraint acs_mail_lite_co_qu_no_callb_p_ck
check (valid_email_p in ('t','f')),
extraheaders clob,
alternative_part_p varchar2(1)
constraint acs_mail_lite_co_qu_alt_part_p_ck
check (valid_email_p in ('t','f')),
use_sender_p varchar2(1)
constraint acs_mail_lite_co_qu_use_sender_p_ck
check (valid_email_p in ('t','f'))
);
-- Make sure that emails are going to parties not to users and therefore logging is for parties, not for users.
alter table acs_mail_lite_bounce_notif drop constraint acs_mail_li_bou_notif_us_id_fk;
alter table acs_mail_lite_bounce_notif add column party_id integer constraint acs_mail_li_bou_notif_us_id_fk references parties (party_id) on delete cascade;
update acs_mail_lite_bounce_notif set party_id = user_id;
alter table acs_mail_lite_bounce_notif drop column user_id;
\ No newline at end of file
alter table acs_mail_lite_complex_queue add column reply_to varchar(400);
\ No newline at end of file
......@@ -5,75 +5,86 @@
-- @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 (
party_id integer
constraint acs_mail_lite_log_party_id_fk
references parties (party_id)
on delete cascade
constraint acs_mail_lite_log_pk
primary key,
last_mail_date timestamptz default current_timestamp
);
create or replace function inline_0 ()
returns integer as '
DECLARE
row RECORD;
v_count integer;
BEGIN
select count(*) into v_count from user_tab_columns
where lower(table_name) = ''acs_mail_lite_queue'';
IF v_count > 0 THEN return 0; END IF;
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
);
create table acs_mail_lite_bounce (
party_id integer
constraint acs_mail_lite_bou_party_id_fk
references parties (party_id)
on delete cascade
constraint acs_mail_lite_bou_pk
primary key,
bounce_count integer default 1
);
return 0;
END;' language 'plpgsql';
select inline_0 ();
drop function inline_0 ();
create table acs_mail_lite_bounce_notif (
party_id integer
constraint acs_mail_li_bou_notif_us_id_fk
references parties (party_id)
on delete cascade
constraint acs_mail_lite_bounce_notif_pk
primary key,
notification_time timestamptz default current_timestamp,
notification_count integer default 0
);
CREATE TABLE acs_mail_lite_complex_queue (
id integer
constraint acs_mail_lite_complex_queue_pk
primary key,
creation_date text,
locking_server text,
to_party_ids text,
cc_party_ids text,
bcc_party_ids text,
to_group_ids text,
cc_group_ids text,
bcc_group_ids text,
to_addr text,
cc_addr text,
bcc_addr text,
from_addr text,
reply_to text,
subject text,
body text,
package_id integer,
files text,
file_ids text,
folder_ids text,
mime_type text,
object_id integer,
single_email_p boolean,
no_callback_p boolean,
extraheaders text,
alternative_part_p boolean,
use_sender_p boolean
);
......@@ -9,4 +9,5 @@ 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
drop table acs_mail_lite_bounce_notif;
drop TABLE acs_mail_lite_complex_queue;
-- Make sure that emails are going to parties not to users and therefore logging is for parties, not for users.
alter table acs_mail_lite_mail_log add column party_id integer references parties(party_id);
update acs_mail_lite_mail_log set party_id = user_id;
alter table acs_mail_lite_mail_log drop column user_id;
alter table acs_mail_lite_bounce add column party_id integer references parties(party_id);
update acs_mail_lite_bounce set party_id = user_id;
alter table acs_mail_lite_bounce drop column user_id;
\ No newline at end of file
-- 2006/11/17 cognovis/nfl
--
-- Name: acs_mail_lite_complex_queue; Type: TABLE; Schema: public; Owner: cognovis; Tablespace:
--
CREATE TABLE acs_mail_lite_complex_queue (
id serial PRIMARY KEY,
creation_date text,
locking_server text,
to_party_ids text,
cc_party_ids text,
bcc_party_ids text,
to_group_ids text,
cc_group_ids text,
bcc_group_ids text,
to_addr text,
cc_addr text,
bcc_addr text,
from_addr text,
subject text,
body text,
package_id integer,
files text,
file_ids text,
folder_ids text,
mime_type text,
object_id integer,
single_email_p boolean,
no_callback_p boolean,
extraheaders text,
alternative_part_p boolean,
use_sender_p boolean
);
--
-- PostgreSQL database statements - end of file
--
-- Make sure that emails are going to parties not to users and therefore logging is for parties, not for users.
alter table acs_mail_lite_bounce_notif drop constraint acs_mail_li_bou_notif_us_id_fk;
alter table acs_mail_lite_bounce_notif add column party_id integer constraint acs_mail_li_bou_notif_us_id_fk references parties (party_id) on delete cascade;
update acs_mail_lite_bounce_notif set party_id = user_id;
alter table acs_mail_lite_bounce_notif drop column user_id;
\ No newline at end of file
alter table acs_mail_lite_complex_queue add column reply_to text;
\ No newline at end of file
# packages/acs-mail-lite/tcl/acs-mail-lite-callback-procs.tcl
ad_library {
Callback procs for acs-mail-lite
@author Malte Sussdorff (sussdorff@sussdorff.de)
@creation-date 2005-06-15
@arch-tag: d9aec4df-102d-4b0d-8d0e-3dc470dbe783
@cvs-id $Id$
}
ad_proc -public -callback acs_mail_lite::complex_send {
{-package_id:required}
{-from_party_id:required}
{-from_addr ""}
{-to_party_ids}
{-cc_party_ids}
{-bcc_party_ids}
{-to_addr}
{-cc_addr}
{-bcc_addr}
{-body}
{-message_id:required}
{-subject}
{-object_id}
{-file_ids}
} {
Callback for executing code after an email has been send using the complex send mechanism.
@param from_party_id Who is sending the email
@param to_party_ids list of ids to whom did we send this email
@param cc_party_ids list of ids to whom did we send this email in "CC"
@param bcc_party_ids list of ids to whom did we send this email in "BCC"
@param to_addr string of emails seperated by "," to whom did we send this email
@param cc_addr string of emails seperated by "," to whom did we send this email in CC
@param bcc_addr string of emails seperated by "," to whom did we send this email in BCC
@param subject of the email
@param body Text body of the email
@param package_id Package ID of the sending package
@param file_ids List of file ids to be send as attachments. This will only work with files stored in the file system. The list is actually a string with the ids concated with a ",".
@param object_id The ID of the object that is responsible for sending the mail in the first place
@param message_id the generated message_id for this mail
} -
ad_proc -public -callback acs_mail_lite::send {
{-package_id:required}
{-from_party_id:required}
{-to_party_id:required}
{-body}
{-message_id:required}
{-subject}
} {
}
ad_proc -public -callback acs_mail_lite::incoming_email {
-array:required
-package_id
} {
Callback that is executed for incoming e-mails if the email is *NOT* like $object_id@servername
} -
ad_proc -public -callback acs_mail_lite::incoming_object_email {
-array:required
-object_id:required
} {
Callback that is executed for incoming e-mails if the email is like $object_id@servername
} -
ad_proc -public -callback acs_mail_lite::email_form_elements {
-varname:required
} {
}
ad_proc -public -callback acs_mail_lite::files {
-varname:required
-recipient_ids:required
} {
}
ad_proc -public -callback acs_mail_lite::incoming_email -impl acs-mail-lite {
-array:required
-package_id:required
} {
Implementation of the interface acs_mail_lite::incoming_email for acs-mail-lite. This proc
takes care of emails bounced back from mailer deamons. The required syntax for the To header
is as follows: EnvelopPrefix-user_id-signature-package_id@myhost.com. This email was set for
the Return-Path header of the original email. The signature is created by calculating the SHA
value of the original Message-Id header. Thus an email is valid if the signature is correct and
the user is known. If this is the case we record the bounce.
@author Nima Mazloumi (nima.mazloumi@gmx.de)
@creation-date 2005-07-15
@param array An array with all headers, files and bodies. To access the array you need to use upvar.
@param package_id The package instance that registered the prefix
@return nothing
@error
} {
upvar $array email
set to [acs_mail_lite::parse_email_address -email $email(to)]
ns_log Debug "acs_mail_lite::incoming_email -impl acs-mail-lite called. Recepient $to"
util_unlist [acs_mail_lite::parse_bounce_address -bounce_address $to] user_id package_id signature
# If no user_id found or signature invalid, ignore message
if {$user_id eq ""} {
if {$user_id eq ""} {
ns_log Debug "acs_mail_lite::incoming_email impl acs-mail-lite: No equivalent user found for $to"
} else {
ns_log Debug "acs_mail_lite::incoming_email impl acs-mail-lite: Invalid mail signature $signature"
}
} else {
ns_log Debug "acs_mail_lite::incoming_email impl acs-mail-lite: Bounce checking $to, $user_id"
if { ![acs_mail_lite::bouncing_user_p -user_id $user_id] } {
ns_log Debug "acs_mail_lite::incoming_email impl acs-mail-lite: Bouncing email from user $user_id"
# record the bounce in the database
db_dml record_bounce {}
if {![db_resultrows]} {
db_dml insert_bounce {}
}
}
}
}
<?xml version="1.0"?>
<queryset>
<fullquery name="callback::acs_mail_lite::incoming_email::impl::acs-mail-lite.record_bounce">
<querytext>
update acs_mail_lite_bounce
set bounce_count = bounce_count + 1
where party_id = :user_id
</querytext>
</fullquery>
<fullquery name="callback::acs_mail_lite::incoming_email::impl::acs-mail-lite.insert_bounce">
<querytext>
insert into acs_mail_lite_bounce (party_id, bounce_count)
values (:user_id, 1)
</querytext>
</fullquery>
</queryset>
......@@ -10,11 +10,17 @@ ad_library {
# Default interval is 1 minute.
ad_schedule_proc -thread t 60 acs_mail_lite::sweeper
# Run the complex_sweeper every 180s (3min)
ad_schedule_proc -thread t 180 acs_mail_lite::complex_sweeper
set queue_dir [parameter::get_from_package_key -parameter "BounceMailDir" -package_key "acs-mail-lite"]
# ad_schedule_proc -thread t 120 acs_mail_lite::load_mails -queue_dir $queue_dir
# 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
#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
# ad_schedule_proc -thread t -schedule_proc ns_schedule_daily [list 0 25] acs_mail_lite::check_bounces
......@@ -3,55 +3,6 @@
<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
......@@ -68,7 +19,7 @@
update acs_mail_lite_mail_log
set last_mail_date = sysdate
where user_id = :user_id
where party_id = :user_id
</querytext>
</fullquery>
......@@ -76,7 +27,7 @@
<fullquery name="acs_mail_lite::log_mail_sending.insert_log_entry">
<querytext>
insert into acs_mail_lite_mail_log (user_id, last_mail_date)
insert into acs_mail_lite_mail_log (party_id, last_mail_date)
values (:user_id, sysdate)
</querytext>
......
......@@ -3,55 +3,6 @@
<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
......@@ -68,7 +19,7 @@
update acs_mail_lite_mail_log
set last_mail_date = current_timestamp
where user_id = :user_id
where party_id = :user_id
</querytext>
</fullquery>
......@@ -76,7 +27,7 @@
<fullquery name="acs_mail_lite::log_mail_sending.insert_log_entry">
<querytext>
insert into acs_mail_lite_mail_log (user_id, last_mail_date)
insert into acs_mail_lite_mail_log (party_id, last_mail_date)
values (:user_id, current_timestamp)
</querytext>
......@@ -114,5 +65,4 @@
</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
where party_id = :user_id
</querytext>
</fullquery>
......@@ -37,59 +14,27 @@
<fullquery name="acs_mail_lite::log_mail_sending.insert_log_entry">
<querytext>
insert into acs_mail_lite_mail_log (user_id, last_mail_date)
insert into acs_mail_lite_mail_log (party_id, last_mail_date)
values (:user_id, sysdate)
</querytext>
</fullquery>
<fullquery name="acs_mail_lite::load_mail_dir.record_bounce">
<fullquery name="acs_mail_lite::smtp.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)
where party_id = :rcpt_id
</querytext>
</fullquery>
<fullquery name="acs_mail_lite::check_bounces.delete_log_if_no_recent_bounce">
<fullquery name="acs_mail_lite::smtp.insert_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
insert into acs_mail_lite_bounce (party_id, bounce_count)
values (:rcpt_id, 1)
</querytext>
</fullquery>
......@@ -97,9 +42,12 @@
<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
select person_id as user_id, first_names || ' ' || last_name as user_name
from parties, persons
where email = :email
and party_id = person_id
order by party_id desc
limit 1
</querytext>
</fullquery>
......@@ -114,6 +62,4 @@
</fullquery>
</queryset>
<?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
(party_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.party_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 party_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 party_id in (select party_id
from acs_mail_lite_mail_log
where last_mail_date < sysdate - :max_days_to_bounce)
</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 (party_id, notification_count, notification_time)
select party_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.party_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 party_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 party_id in (select party_id
from acs_mail_lite_mail_log
where last_mail_date < current_timestamp - to_interval(:max_days_to_bounce, 'days'))
</querytext>
</fullquery>
</queryset>
ad_library {
Provides a simple API for reliably sending email.
@author Eric Lorenzo (eric@openforce.net)
@creation-date 22 March 2002
@cvs-id $Id$
}
package require mime 1.4
package require smtp 1.4
package require base64 2.3.1
namespace eval acs_mail_lite {
#---------------------------------------
ad_proc -private bounce_sendmail {} {
@returns path to the sendmail executable
} {
return [get_parameter -name "SendmailBin"]
}
#---------------------------------------
ad_proc -private bounce_prefix {} {
@returns bounce prefix for x-envelope-from
} {
return [get_parameter -name "EnvelopePrefix"]
}
#---------------------------------------
ad_proc -public bouncing_email_p {
-email:required
} {
Checks if email address is bouncing mail
@option email email address to be checked for bouncing
@returns boolean 1 if bouncing 0 if ok.
} {
return [db_string bouncing_p {} -default 0]
}
#---------------------------------------
ad_proc -public bouncing_user_p {
-user_id:required
} {
Checks if email address of user is bouncing mail
@option user_id user to be checked for bouncing
@returns boolean 1 if bouncing 0 if ok.
} {
return [db_string bouncing_p {} -default 0]
}
#---------------------------------------
ad_proc -public bounce_address {
-user_id:required
-package_id:required
-message_id:required
} {
Composes a bounce address
@option user_id user_id of the mail recipient
@option package_id package_id of the mail sending package
(needed to call package-specific code to deal with bounces)
@option message_id message-id of the mail
@returns bounce address
} {
return "[bounce_prefix]-$user_id-[ns_sha1 $message_id]-$package_id@[address_domain]"
}
#---------------------------------------
ad_proc -public parse_bounce_address {
-bounce_address:required
} {
This takes a reply address, checks it for consistency,
and returns a list of user_id, package_id and bounce_signature found
@option bounce_address bounce address to be checked
@returns tcl-list of user_id package_id bounce_signature
} {
set regexp_str "\[[bounce_prefix]\]-(\[0-9\]+)-(\[^-\]+)-(\[0-9\]*)\@"
if {![regexp $regexp_str $bounce_address all user_id signature package_id]} {
ns_log Debug "acs-mail-lite: bounce address not found for $bounce_address"
return ""
}
return [list $user_id $package_id $signature]
}
#---------------------------------------
ad_proc -public scan_replies {} {
Scheduled procedure that will scan for bounced mails
} {
# Make sure that only one thread is processing the queue at a time.
if {[nsv_incr acs_mail_lite check_bounce_p] > 1} {
nsv_incr acs_mail_lite check_bounce_p -1
return
}
with_finally -code {
ns_log Debug "acs-mail-lite: about to load qmail queue for [mail_dir]"
load_mails -queue_dir [mail_dir]
} -finally {
nsv_incr acs_mail_lite check_bounce_p -1
}
}
#---------------------------------------
ad_proc -private check_bounces { } {
Daily proc that sends out warning mail that emails
are bouncing and disables emails if necessary
} {
set max_bounce_count [get_parameter -name MaxBounceCount -default 10]
set max_days_to_bounce [get_parameter -name MaxDaysToBounce -default 3]
set notification_interval [get_parameter -name NotificationInterval -default 7]
set max_notification_count [get_parameter -name MaxNotificationCount -default 4]
set notification_sender [get_parameter -name NotificationSender -default "reminder@[address_domain]"]
# delete all bounce-log-entries for users who received last email
# X days ago without any bouncing (parameter)
db_dml delete_log_if_no_recent_bounce {}
# disable mail sending for users with more than X recently
# bounced mails
db_dml disable_bouncing_email {}
# notify users of this disabled mail sending
db_dml send_notification_to_bouncing_email {}
# now delete bounce log for users with disabled mail sending
db_dml delete_bouncing_users_from_log {}
set subject "[ad_system_name] Email Reminder"
# now periodically send notifications to users with
# disabled email to tell them how to reenable the email
set notifications [db_list_of_ns_sets get_recent_bouncing_users {}]
# send notification to users with disabled email
foreach notification $notifications {
set notification_list [util_ns_set_to_list -set $notification]
array set user $notification_list
set user_id $user(user_id)
set body "Dear $user(name),\n\nDue to returning mails from your email account, we currently do not send you any email from our system. To reenable your email account, please visit\n[ad_url]/register/restore-bounce?[export_url_vars user_id]"
send -to_addr $notification_list -from_addr $notification_sender -subject $subject -body $body -valid_email
ns_log Notice "Bounce notification send to user $user_id"
# schedule next notification
db_dml log_notication_sending {}
}
}
}
<?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 users, parties
where lower(email) = lower(:email)
and party_id = user_id
</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 users
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 party_id in (select party_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 party_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>
</queryset>
<?xml version="1.0"?>
<queryset>
<rdbms><type>oracle</type><version>8.1.6</version></rdbms>
<fullquery name="acs_mail_lite::complex_send.create_complex_queue_entry">
<querytext>
insert into acs_mail_lite_complex_queue
(id,
creation_date,
locking_server,
to_party_ids,
cc_party_ids,
bcc_party_ids,
to_group_ids,
cc_group_ids,
bcc_group_ids,
to_addr,
cc_addr,
bcc_addr,
from_addr,
reply_to,
subject,
body,
package_id,
files,
file_ids,
folder_ids,
mime_type,
object_id,
single_email_p,
no_callback_p,
extraheaders,
alternative_part_p,
use_sender_p
)
values
(acs_mail_lite_id_seq.nextval,
:creation_date,
:locking_server,
:to_party_ids,
:cc_party_ids,
:bcc_party_ids,
:to_group_ids,
:cc_group_ids,
:bcc_group_ids,
:to_addr,
:cc_addr,
:bcc_addr,
:from_addr,
:reply_to,
:subject,
:body,
:package_id,
:files,
:file_ids,
:folder_ids,
:mime_type,
:object_id,
decode(:single_email_p,'1','t','f'),
decode(:no_callback_p,'1','t','f'),
:extraheaders,
decode(:alternative_part_p,'1','t','f'),
decode(:use_sender_p,'1','t','f')
)
</querytext>
</fullquery>
<fullquery name="acs_mail_lite::complex_sweeper.get_complex_queued_messages">
<querytext>
select
id,
creation_date,
locking_server,
to_party_ids,
cc_party_ids,
bcc_party_ids,
to_group_ids,
cc_group_ids,
bcc_group_ids,
to_addr,
cc_addr,
bcc_addr,
from_addr,
subject,
body,
package_id,
files,
file_ids,
folder_ids,
mime_type,
object_id,
decode(single_email_p,'t',1,0) as single_email_p,
decode(no_callback_p,'t',1,0) as no_callback_p,
extraheaders,
decode(alternative_part_p,'t',1,0) as alternative_part_p,
decode(use_sender_p,'t',1,0) as use_sender_p
from acs_mail_lite_complex_queue
where locking_server = '' or locking_server is NULL
</querytext>
</fullquery>
</queryset>
<?xml version="1.0"?>
<queryset>
<rdbms><type>postgresql</type><version>7.1</version></rdbms>
<fullquery name="acs_mail_lite::complex_send.create_complex_queue_entry">
<querytext>
insert into acs_mail_lite_complex_queue
(id,
creation_date,
locking_server,
to_party_ids,
cc_party_ids,
bcc_party_ids,
to_group_ids,
cc_group_ids,
bcc_group_ids,
to_addr,
cc_addr,
bcc_addr,
from_addr,
reply_to,
subject,
body,
package_id,
files,
file_ids,
folder_ids,
mime_type,
object_id,
single_email_p,
no_callback_p,
extraheaders,
alternative_part_p,
use_sender_p
)
values
(nextval('acs_mail_lite_id_seq'),
:creation_date,
:locking_server,
:to_party_ids,
:cc_party_ids,
:bcc_party_ids,
:to_group_ids,
:cc_group_ids,
:bcc_group_ids,
:to_addr,
:cc_addr,
:bcc_addr,
:from_addr,
:reply_to,
:subject,
:body,
:package_id,
:files,
:file_ids,
:folder_ids,
:mime_type,
:object_id,
(case when :single_email_p = '1' then TRUE else FALSE end),
(case when :no_callback_p = '1' then TRUE else FALSE end),
:extraheaders,
(case when :alternative_part_p = '1' then TRUE else FALSE end),
(case when :use_sender_p = '1' then TRUE else FALSE end)
)
</querytext>
</fullquery>
<fullquery name="acs_mail_lite::complex_sweeper.get_complex_queued_messages">
<querytext>
select
id,
creation_date,
locking_server,
to_party_ids,
cc_party_ids,
bcc_party_ids,
to_group_ids,
cc_group_ids,
bcc_group_ids,
to_addr,
cc_addr,
bcc_addr,
from_addr,
reply_to,
subject,
body,
package_id,
files,
file_ids,
folder_ids,
mime_type,
object_id,
(case when single_email_p = TRUE then 1 else 0 end) as single_email_p,
(case when no_callback_p = TRUE then 1 else 0 end) as no_callback_p,
extraheaders,
(case when alternative_part_p = TRUE then 1 else 0 end) as alternative_part_p,
(case when use_sender_p = TRUE then 1 else 0 end) as use_sender_p
from acs_mail_lite_complex_queue
where locking_server = '' or locking_server is NULL
</querytext>
</fullquery>
</queryset>
This diff is collapsed.
<?xml version="1.0"?>
<queryset>
<fullquery name="acs_mail_lite::complex_sweeper.get_complex_queued_message">
<querytext>
select id
from acs_mail_lite_complex_queue
where id=:id and (locking_server = '' or locking_server is NULL)
</querytext>
</fullquery>
<fullquery name="acs_mail_lite::complex_sweeper.lock_queued_message">
<querytext>
update acs_mail_lite_complex_queue
set locking_server = :locking_server
where id=:id
</querytext>
</fullquery>
<fullquery name="acs_mail_lite::complex_sweeper.delete_complex_queue_entry">
<querytext>
delete from acs_mail_lite_complex_queue
where id=:id
</querytext>
</fullquery>
</queryset>
ad_library {
Provides a simple API for reliably sending email.
@author Eric Lorenzo (eric@openforce.net)
@creation-date 22 March 2002
@cvs-id $Id$
}
package require mime 1.4
package require smtp 1.4
package require base64 2.3.1
namespace eval acs_mail_lite {
#---------------------------------------
ad_proc -public address_domain {} {
@returns domain address to which bounces are directed to
} {
set domain [get_parameter -name "BounceDomain"]
if { $domain eq "" } {
regsub {http://} [ns_config ns/server/[ns_info server]/module/nssock hostname] {} domain
}
return $domain
}
#---------------------------------------
ad_proc -private load_mails {
-queue_dir:required
} {
Scans for incoming email. You need
An incoming email has to comply to the following syntax rule:
[<SitePrefix>][-]<ReplyPrefix>-Whatever@<BounceDomain>
[] = optional
<> = Package Parameters
If no SitePrefix is set we assume that there is only one OpenACS installation. Otherwise
only messages are dealt with which contain a SitePrefix.
ReplyPrefixes are provided by packages that implement the callback acs_mail_lite::incoming_email
and provide a package parameter called ReplyPrefix. Only implementations are considered where the
implementation name is equal to the package key of the package.
Also we only deal with messages that contain a valid and registered ReplyPrefix.
These prefixes are automatically set in the acs_mail_lite_prefixes table.
@author Nima Mazloumi (nima.mazloumi@gmx.de)
@creation-date 2005-07-15
@option queue_dir The location of the qmail mail (BounceMailDir) queue in the file-system i.e. /home/service0/mail.
@see acs_mail_lite::incoming_email
@see acs_mail_lite::parse_email
} {
# get list of all incoming mail
if {[catch {
set messages [glob "$queue_dir/new/*"]
} errmsg]} {
if {[string match "no files matched glob pattern*" $errmsg ]} {
ns_log Debug "load_mails: queue dir = $queue_dir/new/*, no messages"
} else {
ns_log Error "load_mails: queue dir = $queue_dir/new/ error $errmsg"
}
return [list]
}
# loop over every incoming mail
foreach msg $messages {
ns_log Debug "load_mails: opening $msg"
array set email {}
# This will parse the E-mail and extract the files to the file system
parse_email -file $msg -array email
set email(to) [parse_email_address -email $email(to)]
set email(from) [parse_email_address -email $email(from)]
set subject [lindex $email(subject) 0]
if {$email(bodies) eq ""} {
ad_script_abort
ns_log Notice "E-Mail without body"
}
# Do no execute any callbacks if the email is an autoreply.
# Thanks to Vinod for the idea and the code
set callback_executed_p [acs_mail_lite::autoreply_p -subject $subject -from $email(from)]
if {!$callback_executed_p} {
# Special treatment for e-mails which look like they contain an object_id
set pot_object_id [lindex [split $email(to) "@"] 0]
if {[ad_var_type_check_number_p $pot_object_id]} {
if {[acs_object::object_p -id $pot_object_id]} {
callback acs_mail_lite::incoming_object_email -array email -object_id $pot_object_id
# Mark that the callback has been executed already
set no_callback_p 1
}
}
}
if {!$callback_executed_p} {
# We execute all callbacks now
callback acs_mail_lite::incoming_email -array email
}
#let's delete the file now
if {[catch {ns_unlink $msg} errmsg]} {
ns_log Error "load_mails: unable to delete queued message $msg: $errmsg"
} else {
ns_log Debug "load_mails: deleted $msg"
}
}
}
#---------------------------------------
ad_proc parse_email {
-file:required
-array:required
} {
An email is splitted into several parts: headers, bodies and files lists and all headers directly.
The headers consists of a list with header names as keys and their correponding values. All keys are lower case.
The bodies consists of a list with two elements: content-type and content.
The files consists of a list with three elements: content-type, filename and content.
The array with all the above data is upvared to the caller environment.
Important headers are:
-message-id (a unique id for the email, is different for each email except it was bounced from a mailer deamon)
-subject
-from
-to
Others possible headers:
-date
-received
-references (this references the original message id if the email is a reply)
-in-reply-to (this references the original message id if the email is a reply)
-return-path (this is used for mailer deamons to bounce emails back like bounce-user_id-signature-package_id@service0.com)
Optional application specific stuff only exist in special cases:
X-Mozilla-Status
X-Virus-Scanned
X-Mozilla-Status2
X-UIDL
X-Account-Key
X-Sasl-enc
You can therefore get a value for a header either through iterating the headers list or simply by calling i.e. "set message_id $email(message-id)".
Note: We assume "application/octet-stream" for all attachments and "base64" for
as transfer encoding for all files.
Note: tcllib required - mime, base64
@author Nima Mazloumi (nima.mazloumi@gmx.de)
@creation-date 2005-07-15
} {
upvar $array email
#prepare the message
if {[catch {set mime [mime::initialize -file $file]} errormsg]} {
ns_log error "Email could not be delivered for file $file"
set stream [open $file]
set content [read $stream]
close $stream
ns_log error "$content"
ns_unlink $file
return
}
#get the content type
set content [mime::getproperty $mime content]
#get all available headers
set keys [mime::getheader $mime -names]
set headers [list]
# create both the headers array and all headers directly for the email array
foreach header $keys {
set value [mime::getheader $mime $header]
set email([string tolower $header]) $value
lappend headers [list $header $value]
}
set email(headers) $headers
#check for multipart, otherwise we only have one part
if { [string first "multipart" $content] != -1 } {
set parts [mime::getproperty $mime parts]
} else {
set parts [list $mime]
}
# travers the tree and extract parts into a flat list
set all_parts [list]
foreach part $parts {
if {[mime::getproperty $part content] eq "multipart/alternative"} {
foreach child_part [mime::getproperty $part parts] {
lappend all_parts $child_part
}
} else {
lappend all_parts $part
}
}
set bodies [list]
set files [list]
#now extract all parts (bodies/files) and fill the email array
foreach part $all_parts {
# Attachments have a "Content-disposition" part
# Therefore we filter out if it is an attachment here
if {[catch {mime::getheader $part Content-disposition}] || [mime::getheader $part Content-disposition] eq "inline"} {
switch [mime::getproperty $part content] {
"text/plain" {
lappend bodies [list "text/plain" [mime::getbody $part]]
}
"text/html" {
lappend bodies [list "text/html" [mime::getbody $part]]
}
}
} else {
set encoding [mime::getproperty $part encoding]
set body [mime::getbody $part -decode]
set content $body
set params [mime::getproperty $part params]
array set param $params
# Append the file if there exist a filename to use. Otherwise do not append
if {[exists_and_not_null param(name)]} {
set filename $param(name)
# Determine the content_type
set content_type [mime::getproperty $part content]
if {$content_type eq "application/octet-stream"} {
set content_type [ns_guesstype $filename]
}
lappend files [list $content_type $encoding $filename $content]
}
}
}
set email(bodies) $bodies
set email(files) $files
#release the message
mime::finalize $mime -subordinates all
}
ad_proc -public autoreply_p {
{-subject ""}
{-from ""}
} {
Parse the subject, from and body to determin if the email is an auto reply
Typical autoreplies are "Out of office" messages. This is what the procedure does
@param subject Subject of the Email that will be scanned for "out of office"
@param from From address which will be checked if it is coming from a mailer daemon
@return 1 if this is actually an autoreply
} {
set autoreply_p 0
if {$subject ne ""} {
# check subject
set autoreply_p [regexp -nocase "(out of.*office|automated response|autoreply)" $subject]
set autoreply_p [regexp "NDN" $subject]
set autoreply_p [regexp "\[QuickML\] Error" $subject]
}
if {$from ne ""} {
# check from if it comes from the mailer daemon
set autoreply_p [regexp -nocase "mailer.*daemon" $from]
}
return $autoreply_p
}
}
\ No newline at end of file
<master>
<property name="title">@page_title;noquote@</property>
<property name="context">@context;noquote@</property>
<p>#acs-mail-lite.Bounce_disabled#</p>
<p>
<b>&raquo;</b> <a href="@return_url@">#acs-subsite.Continue#</a>
</p>
ad_page_contract {
The page restores a user from the deleted state.
@cvs-id $Id$
} {
{return_url {[ad_pvt_home]}}
}
set page_title [_ acs-mail-lite.Restore_bounce]
set context [list [list [ad_pvt_home] [ad_pvt_home_name]] $page_title]
# We do require authentication, though their account will be closed
set user_id [auth::require_login]
db_dml unbounce_user "update users set email_bouncing_p = 'f' where user_id = :user_id"
# Used in a message key
set system_name [ad_system_name]
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