Mail.pm
Проделанные изменения про которые не соит забывать
* Функции mailitem, mailitem_to_addr и process_mailto получили дополнительный (самый первый) аргумент, контекст формы. Он становится родительским контекстом для создаваемого контекста документа.
* Все (?), что надо переписано для работы с новой системой контекстов.
* process_sendmail в качестве сообщения принимает собственно текст, а не объект MIME::Lite.
* Удалена функция mail_as_attach.
* Функция encode_header закомментирована - до разбирательства.
* Функция convert_to_plain перенсена в Document::convert.
NAME
Communiware::Mail - sends mail, generated by Communiware templates.
SYNOPSIS
@emails = mailitem($ctx, $item, $template, $format, $filter); @emails = mailitem_to_addr($ctx, $item, $template, $format, @address_list); process_sendmail($message, [@addresses], ...);
process_mailto($ctx, $mailspec, $item);
DESCRIPTION
This module contains functions related to sending E-Mail from Communiware server.
FUNCTIONS
sendmail
system(Communiware::Mail::sendmail(),@args) MIME::Lite->send('sendmail', Communiware::Mail::sendmail()." -t -oi -oem ");
In scalar context returns path to the sendmail program as configured in the
distribution, in list context returns @Communiware::Mail::sendmail
variable.
If @Communiware::Mail::sendmail
variable is already defined, it is used (its
first element in scalar context), otherwise the function sets
@Communiware::Mail::sendmail
.
Dies while initializing @Communiware::Mail::sendmail
if configured sendmail
program is not executable.
mailitem
@emails = mailitem($ctx, $item_id, $template_id, $convert_to_plain,$filter,\%headers);
Prepares item '$item_id
' presented by template '$template_id
' to send as
email message to persons specified by filter '$filter
'.
Return value is suitable as input for process_sendmail function (see process_sendmail).
'$convert_to_plain
' and '{%headers}
' arguments are submitted as is to
mailitem_to_addr function, see mailitem_to_addr for their description.
Filter '$filter
' should return item IDs of persons.
mailitem_to_addr
($message, @emails) = mailitem_to_addr($ctx, $item_id, $template, $convert_to_plain, \%headers, @addresses);
Prepares item '$item_id
' presented by template '$template_id
' to send as
email message to email addresses '@addresses
'.
Return value is suitable as input for process_sendmail function (see process_sendmail), it is ready-to-use message (headers and body) and list of mail addresses.
This functions passes actual list of recipients into the envelope, so headers like To, Cc and Bcc can be safely redefined in the template.
Following headers are set to the following default values, unless they are
explicitely defined in the template via <:Header:>
dynamic element:
- From
-
E-Mail of the current user (that is, user with
AUTHOR_ID
mentioned above), or 'Anonymous Communiware User' if this user is undefined - Subject
- Title of the item being sent
- To
- Full list of recipients
- Content-Type
-
text/html
. Redefine it only if you are absolutely sure that your template generates something other than HTML -
text/plain
if '$convert_to_plain
' flag is true
Headers provided in the \%headers parameter override above defaults but are
overridden in turn by headers created from template via <:Header:>
dynamic element.
The function stores following attributes in document_item context:
- PLAIN_TEXT_MAIL
- Is set to 0 if message is not to be converted into plain text and 1 if it is to be converted.
- MAIL_ADDRESSES
- List attribute, contains all addresses which mail is sent to.
process_sendmail
process_sendmail($message,[@addresses],...);
process_sendmail takes list of pairs (ready-to-send message and a reference to
array of it's adressees), and sends each message to those its addressees. The
addresses are used as envelope addresses only and do not appear in message
headers (except address of every recipient in Received:
headers of letter
received by him). That is, there is no disclosure of recipients list.
process_mailto
($message,$addrlist) = process_mailto($mailspec, $item_id);
Processes mail specification as generated by <:MailTo:>
dynamic
element, i.e. list template, filter, format, logical expression joined by ASCII
record separator, and if logical expression is true, returns item '$item
'
presented by given template (see mailitem) to users returned by given
filter, or, if no filter was specified, to address specified in OLD_URL field
of template.
Return value is suitable as input for process_sendmail function (see process_sendmail).
It is defined here because it is used by dynamic element itself and by posting handler.
insert_into_user_list
insert_into_user_list(\%store,\%item,$is_from_original_filter);
Internal function used from 'expand_user_list
' (see expand_user_list) to
insert item into item list. If %item
has no ITEM_ID
attribute it is added
to empty key array in %store
. If it has and it $is_from_original_filter
its attributes override those that are already in %store
for this item ID,
otherwise only attributes that are new to %store
are added.
expand_user_list
@expanded_list = expand_user_list($ctx, $filter); or $expanded_list = expand_user_list($ctx, $filter);
This function receives Communiware filter (specification or
Communiware::Filter
object) and expands groups (i.e. items in it that can be
passive ends in the INCLUDED_USER_GROUP
link and have no EMAIL
attribute
brought by filter) to its non-group members. When expanding duplicates are
removed, while known attributes are merged.
Return value: list (list reference in scalar context) of anonymous hashes. Each
hash corresponds to non-group element (from $filter
or from expansion) and
contains all attributes known from the filter and intermediate queries.
Attributes from different instances (i.e. from expansion of different groups or
from expansion and $filter
) are merged, and attributes from member's element
in $filter
override those from expansion. For resulting elements an EMAIL
attribute is filled, if possible.