I still need to verify everthing. You example in the docs works very well.
Now I need a working example for attachments. acs-mail breaks in postgres. Brian conformed this to work on Oracle thou:
set generated_name "test"
set csv_string "contents of csv file"
set csv_file_name "outputfilename.csv"
set file_handle [open $csv_file_name w]
puts $file_handle $csv_string
close $file_handle
set ip_addr [ad_conn peeraddr]
set modifying_user [ad_conn user_id]
set from_addr [db_string some_sql "select email from parties where
party_id = :modifying_user"]
# create the multipart message ('multipart/mixed')
set multipart_id [acs_mail_multipart_new -multipart_kind "mixed"]
# create an acs_mail_body (with content_item_id = multipart_id )
set body_id [acs_mail_body_new -header_subject $generated_name
-content_item_id $multipart_id ]
# create a new text/plain item
set content_item_id [db_exec_plsql create_text_item {
begin
:1 := content_item.new (
name => :generated_name,
title => :generated_name,
mime_type => 'text/plain',
text => :csv_string);
end;}]
set sequence_num [acs_mail_multipart_add_content -multipart_id
$multipart_id -content_item_id $content_item_id]
db_dml update_multiparts "
update acs_mail_multipart_parts
set mime_disposition='attachment; filename=\"$generated_name\"'
where sequence_number=:sequence_num
and multipart_id=:multipart_id"
# queue it
set mail_link_id [db_exec_plsql queue_the_mail {
begin
:1 := acs_mail_queue_message.new (
null, -- p_mail_link_id
:body_id, -- p_body_id
null, -- p_context_id
sysdate, -- p_creation_date
:modifying_user, -- p_creation_user
:ip_addr, -- p_creation_ip
'acs_mail_link' -- p_object_type
);
end;
}
]
# send a copy of the mail to the logged in user
set sql_string "
insert into acs_mail_queue_outgoing
( message_id, envelope_from, envelope_to )
values
( :mail_link_id, :from_addr, :to_addr )"
set to_addr $from_addr
if {![empty_string_p $to_addr]} {
db_dml outgoing_queue $sql_string
} else {
ns_log Error "To email address is blank"
}
In postgres when I call
set body_id [acs_mail_body_new -header_subject $generated_name
-content_item_id $multipart_id ]
I get the following error
ERROR: Function acs_mail_body__new("unknown", "unknown", "unknown", "unknown",
"unknown", "unknown", "unknown", "unknown", "unknown", "unknown", "unknown",
timestamptz, "unknown", "unknown", "unknown") does not exist
Unable to identify a function that satisfies the given argument types
You may need to add explicit typecasts
SQL:
select acs_mail_body__new (
NULL, -- body_id
NULL, -- body_reply_to
NULL, -- body_from
NULL, -- body_date
NULL, -- header_message_id
NULL, -- header_reply_to
'test', -- header_subject
NULL, -- header_from
NULL, -- header_to
'2015', -- content_item_id
'acs_mail_body', -- object_type
now(), -- creation_date
NULL, -- creation_user
NULL, -- creation_ip
null -- context_id
);
The function doesn't exists. So I assume that noone is really maintaining or using acs-mail.