The site sends two letters: on registration and on a request for a new password. It sends them with PHP's mail(), or through an SMTP server with a client of its own, without third-party libraries.
SMTP
Set mail.smtp in the configuration; without host the site uses mail():
'mail' => array(
'from' => 'Site <[email protected]>',
'smtp' => array(
'host' => 'smtp.example.org',
'port' => 587,
'encryption' => 'tls',
'username' => '[email protected]',
'password' => '…',
// 'cafile' => '/path/to/ca.pem',
'timeout' => 15,
),
),
encryption:tlsorstarttls— STARTTLS, and the letter is not sent if the server does not offer it;ssl— TLS from the start (port 465); an empty string — none, and then the password travels in clear. Without it: port 25, no encryption, 15 seconds.- The client signs in with AUTH PLAIN or LOGIN, whichever the server offers, and checks the server's certificate against its name;
cafileadds a private certificate authority. fromis the sender of every letter, with or without a name. Letters are sent as text and HTML in UTF-8, with the sender asReply-ToandReturn-Path.
The configuration template's block is commented out, and the installed from is [email protected]: change it. php index.php setup check warns about both.
Letter templates
| Template | When | Placeholders |
|---|---|---|
user_registration |
registration | [user_name], [user_login], [password_link], [site_name], [site_url] |
user_restore_password |
a request for a new password | [sex_suffix_hello], [user_name], [user_login], [restore_link], [site_name], [site_url] |
«Шаблоны писем» (Mail templates) — /admin/mail-templates/ — edits each template per language: «Тема письма» (Subject), the text and the HTML of the letter; «Подсказки» (Hints) lists the placeholders. A template can't be deleted, only switched off — and a switched-off template stops its letter with «Не найден активный шаблон письма» (No active mail template). Placeholders are filled in the language of the page; in the HTML they are escaped.
[site_name] comes from different places: the registration letter takes the interface string TXT_SITE_NAME, the password letter the site's name in «Настройки сайта» (Site settings). Set both.
When a letter is not sent
The site writes Mail: <reason> to PHP's error log, and the visitor still sees the usual message. There is no command that sends a test letter: after setting mail up, register a test user or ask for a new password, and look at the log.