This module deals with mail sending and does the SMTP job. It provides a function for message distribution to a list, the message can be encrypted. There is also a function to send service messages by parsing tt2 files, These messages can be signed. For sending, a call to sendmail is done or the message is pushed in a spool according to calling context.

Message is written by parsing a tt2 file (or with a string ). It writes mail headers if they are missing and they are encoded. Then the message is sent by calling mail::sending() function (see mail-sending).

Distributes a message to a list. The message is encrypted if needed, in this case, only one SMTP session is used for each recepient otherwise, recepient are grouped by domain for sending (it controls the number recepient arguments to call sendmail). Message is sent by calling mail::sendto() function (see mail-sendto).

Used by other processes than sympa.pl to indicate to send message by writing message in spool instead of calling mail::smtpto() function (see mail-smtpto). The concerned spool is set in $send_spool global variable, used by mail::sending() function (see mail-sending).

Non blocking function used to clean the defuncts child processes by waiting for them and then decreasing the counter. For exemple, this function is called by mail::smtpto() (see mail-smtpto), main loop of sympa.pl, task_manager.pl, bounced.pl.

IN:

block

OUT: the pid of the defunct process -1 if there is no such child process.

Signs the message according to $sign_mode. Chooses sending mode according to context. If $send_spool global variable is empty, the message is sent by calling mail::smtpto() function (see mail-smtpto) else the message is written in spool $send_spool in order to be handled by sympa.pl process (because only this is allowed to make a fork). When the message is pushed in spool, these mail headers are added:

X-Sympa-To:: recepients

X-Sympa-From:: from

X-Sympa-Checksum:: to check allowed program to push in spool

A message pushed in spool like this will be handled later by sympa::DoSendMessage() function (see sympa-dosendmessage)

from (+): for SMTP: MAIL From: field for spool sending: X-Sympa-From field

robot (+): robot

listname: listname <nowiki

>''</nowiki>

sign_mode (+): 'smime' 'none'for signing

sympa_email: for the file name for spool sending

*

OUT: 1 - sending by calling smtpto() (sendmail) 0 - sending by pushing in spool undef
==== smtpto() ====
Calls to sendmail for the recipients given as argument by making a fork and an exec. Before, waits for number of children process number allowed by sympa.conf by calling mail::reaper() function (see mail-reaper).
IN:
- from (+): SMTPMAIL From: field
- rcpt (+): ref(SCALAR)) ref(ARRAY) - SMTPRCPT To: field
- robot (+): robot
OUT: mail::$fh - file handle on opened file for ouput, for SMTPDATA field undef