Mail: sendmail envelope sender, tip-a-friend sender, SMTP failures and random identifiers (6.0.15)
From 6.0.15 on, the mail layer hands sendmail only a plain envelope sender, content/tipafriend sends as the site,
an SMTP failure of any kind is a failed send instead of an error page, and MIME boundaries and Message-Ids are random.
What changes
- sendmail
-f. Withsite.ini [MailSettings] SendmailEnvelopeSender=enabled(the default) the sender was passed as-f'<address>'. PHP'smail()runsescapeshellcmd()over the whole option string, which undoes that quoting (the pattern of PHPMailer CVE-2016-10033). Measured: the sender"a' -X/tmp/x.php -OQueueDirectory=/tmp '"@example.compasseseZMail::validate()(a quoted local part), and sendmail got-X/tmp/x.phpand-OQueueDirectory=/tmpas arguments of their own. Such a sender is reachable throughcontent/tipafriendand through a form ofcontent/collectinformationthat sets the sender. Now-fis given only for an address of letters, digits and._%+=-before a single@and a host name after it (eZSendmailTransport::isShellSafeAddress()), without extra quoting; any other sender is not handed to sendmail, which then uses its own default, and a warning goes to the debug log. Ordinary addresses are not affected. - Tip a friend. Without
site.ini [TipAFriend] FromEmail(the default) the mail used to be sent with the visitor's address as sender and envelope sender. It is now sent with the site's address, the first valid one of[MailSettings] EmailSenderandAdminEmail(written asaddressorName <address>), and the visitor's address goes intoReply-To. The display name of the sender is then[SiteSettings] SiteName(control characters and quotes removed), not the name the visitor typed, so a visitor cannot make the mail arrive as "Bank support <site address>". A reply still reaches the visitor and the mail passes SPF and DMARC checks of the site's domain. Only when neither setting is a valid address is the visitor's address the sender, as before. WithFromEmailset,Reply-Tois added as well. - SMTP failures.
eZSMTPTransport::sendMail()caught onlyezcMailException. Measured with a fake SMTP server on 127.0.0.1 that offers onlyAUTH NTLM:ezcMailSmtpTransport::authNtlm()threwezcBaseExtensionNotFoundException('mcrypt'), which reached the request (registration, forgotten password). Every other error is now logged and the send returnsfalse. - SMTP authentication method. New
site.ini [MailSettings] TransportAuthMethodpicks the method (PLAIN,LOGIN,CRAM-MD5,DIGEST-MD5,NTLM,XOAUTH2, any case). Empty, the default, keeps the library's choice; an unknown value logs a warning and is ignored. - Credentials in clear. A user name and password sent over an unencrypted connection (
TransportConnectionTypeempty ortcp) to a host other than loopback log a warning. Nothing is refused. - Random identifiers. The
multipart/alternativepart of a mail built from an HTML template got the library's boundary (date( "YmdGHjs" ) . ':' . getmypid() . ':' . counter), and every mail sent by SMTP got a Message-Id of the same parts: the PHP process id was in every mail. The boundary is now the random one of the raw body, and a mail without a Message-Id of its own gets<32 hexadecimal characters@sender domain>(localhostwithout a usable sender domain) for each generation. One set witheZMail::setMessageID()stays. - A mail without sender.
eZMail::senderText()of a mail without a sender gave "Trying to access array offset on false" and "mb_encode_mimeheader(): Passing null to parameter #1" (PHP 8.5). It now returns''quietly. - Not changed. The newsletter (
cjw_newsletter) sends through its own transports and its own return path, and notifications useEmailSenderas before; for plain sender addresses nothing changes for either.
Settings
| Setting | Default | Meaning |
|---|---|---|
site.ini [MailSettings] TransportAuthMethod | empty | the SMTP authentication method; empty = the strongest the server offers |
What to do when you upgrade
- A site whose SMTP server offers
NTLM(common with Microsoft Exchange) could not send by SMTP at all; setTransportAuthMethod=LOGIN(orPLAIN) and useTransportConnectionType=tlsorssl. - A sendmail setup that relied on a sender address with a quoted local part or an address literal as envelope sender
now gets sendmail's default envelope sender; set
EmailSenderto a plain address. - Tip-a-friend mail now comes from the site's address. Set
[TipAFriend] FromEmailto choose another one.
Code and tests
eZSendmailTransport::isShellSafeAddress()(lib/ezutils/classes/ezsendmailtransport.php),eZSMTPTransport::authMethod()andsendsCredentialsInClear()(lib/ezutils/classes/ezsmtptransport.php),Tipafriend::siteSender()andsiteSenderName()(kernel/private/classes/views/content/tipafriend.php),expMailTemplateBody(kernel/classes/mail/expmailtemplatebody.php),ezpMail::messageIdHost()(kernel/private/classes/ezpmail.php),eZMail::composeEmailName()andencodeMimeHeader().- Tests without a database:
eZSendmailEnvelopeSenderTest,eZSMTPTransportTest(with the fake servertests/tests/lib/ezutils/fixtures/smtp_fake_server.php),eZMailTest,expMailTemplateBodyTest,ezpMailMessageIdTest,expTipafriendSenderTest.