Я установил почтовый сервер с Nextcloud, следуя этот учебник. Я создал пользователей и могу читать и отправлять электронные письма из Thunderbird. Я могу читать электронные письма в приложении Nexcloud Mail, но при попытке отправки получаю сообщение об ошибке: Error: Request failed with status code 500
.
Я проверил /var/log/mail.log
и нашли ошибки связанные со STARTTLS:
mail postfix/submission/smtpd[16292]: connect from localhost[127.0.0.1]
mail postfix/submission/smtpd[16292]: lost connection after STARTTLS from localhost[127.0.0.1]
mail postfix/submission/smtpd[16292]: disconnect from localhost[127.0.0.1] ehlo=1 starttls=1 commands=2
Я так понял конфиг Postfix в /etc/postfix/main.cf
должен разрешать соединения с localhost без аутентификации:
smtpd_client_restrictions =
permit_mynetworks
permit_sasl_authenticated
reject_unknown_reverse_client_hostname
smtpd_helo_restrictions =
permit_mynetworks
permit_sasl_authenticated
reject_invalid_helo_hostname
reject_non_fqdn_helo_hostname
reject_unknown_helo_hostname
smtpd_helo_required=yes
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
Почтовые учетные записи в Nextcloud настраиваются с использованием параметров по умолчанию Приложения Auto Mail Accounts:
'auto_mail_accounts' => array (
'imap_host' => 'localhost',
'imap_port' => '143',
'imap_ssl_mode' => 'none',
'smtp_host' => 'localhost',
'smtp_port' => '587',
'smtp_ssl_mode' => 'none',
'email_address_suffix' => ''
),
Поскольку в ошибке упоминается постфикс / отправка, я попытался изменить значения в /etc/postfix/master.cf
, например добавление permit_mynetworks
или замена permit_sasl_authenticated
по permit_mynetworks
. Безуспешно.
Вот исходная настройка:
submission inet n - - - - smtpd
-o syslog_name=postfix/submission
-o smtpd_tls_security_level=encrypt
-o smtpd_client_restrictions=permit_sasl_authenticated,reject
-o cleanup_service_name=header_cleanup
изменить: соответствующий журнал из /var/log/nextcloud.log
, сообщая мне, что он пытается создать соединение TLS:
Aug 22 16:47:45 mail nextcloud[2026]: {"reqId":"8Z3LM0RchxTJzyeFU1Ok","level":3,"time":"2020-08-22T16:47:45+02:00","remoteAddr":"ipv6edited","user":"editedmailaddress","app":"mail","method":"POST","url":"/apps/mail/api/accounts/3/send","message":"{\"Exception\":\"OCA\\\\Mail\\\\Exception\\\\ServiceException\",\"Message\":\"Could not send message: Could not open secure TLS connection to the server.\",\"Code\":100,\"Trace\":[{\"file\":\"/var/www/nextcloud/apps/mail/lib/Controller/AccountsController.php\",\"line\":345,\"function\":\"sendMessage\",\"class\":\"OCA\\\\Mail\\\\Service\\\\MailTransmission\",\"type\":\"->\",\"args\":[{\"__class__\":\"OCA\\\\Mail\\\\Model\\\\NewMessageData\"},null,null,5]},{\"file\":\"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php\",\"line\":170,\"function\":\"send\",\"class\":\"OCA\\\\Mail\\\\Controller\\\\AccountsController\",\"type\":\"->\",\"args\":[3,\"sdfdsf\",\"\",\"recipientmailedited@gmail.com\",\"\",\"\",false,5,null,null,[],null]},{\"file\":\"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php\",\"line\":100,\"function\":\"executeController\",\"class\":\"OC\\\\AppFramework\\\\Http\\\\Dispatcher\",\"type\":\"->\",\"args\":[{\"__class__\":\"OCA\\\\Mail\\\\Controller\\\\AccountsController\"},\"send\"]},{\"file\":\"/var/www/nextcloud/lib/private/AppFramework/App.php\",\"line\":137,\"function\":\"dispatch\",\"class\":\"OC\\\\AppFramework\\\\Http\\\\Dispatcher\",\"type\":\"->\",\"args\":[{\"__class__\":\"OCA\\\\Mail\\\\Controller\\\\AccountsController\"},\"send\"]},{\"file\":\"/var/www/nextcloud/lib/private/AppFramework/Routing/RouteActionHandler.php\",\"line\":47,\"function\":\"main\",\"class\":\"OC\\\\AppFramework\\\\App\",\"type\":\"::\",\"args\":[\"OCA\\\\Mail\\\\Controller\\\\AccountsController\",\"send\",{\"__class__\":\"OC\\\\AppFramework\\\\DependencyInjection\\\\DIContainer\"},{\"accountId\":\"3\",\"_route\":\"mail.accounts.send\"}]},{\"function\":\"__invoke\",\"class\":\"OC\\\\AppFramework\\\\Routing\\\\RouteActionHandler\",\"type\":\"->\",\"args\":[{\"accountId\":\"3\",\"_route\":\"mail.accounts.send\"}]},{\"file\":\"/var/www/nextcloud/lib/private/Route/Router.php\",\"line\":297,\"function\":\"call_user_func\",\"args\":[{\"__class__\":\"OC\\\\AppFramework\\\\Routing\\\\RouteActionHandler\"},{\"accountId\":\"3\",\"_route\":\"mail.accounts.send\"}]},{\"file\":\"/var/www/nextcloud/lib/base.php\",\"line\":1007,\"function\":\"match\",\"class\":\"OC\\\\Route\\\\Router\",\"type\":\"->\",\"args\":[\"/apps/mail/api/accounts/3/send\"]},{\"file\":\"/var/www/nextcloud/index.php\",\"line\":37,\"function\":\"handleRequest\",\"class\":\"OC\",\"type\":\"::\",\"args\":[]}],\"File\":\"/var/www/nextcloud/apps/mail/lib/Service/MailTransmission.php\",\"Line\":176,\"Previous\":{\"Exception\":\"Horde_Mime_Exception\",\"Message\":\"Could not open secure TLS connection to the server.\",\"Code\":100,\"Trace\":[{\"file\":\"/var/www/nextcloud/apps/mail/vendor/pear-pear.horde.org/Horde_Mime/Horde/Mime/Mail.php\",\"line\":479,\"function\":\"send\",\"class\":\"Horde_Mime_Part\",\"type\":\"->\",\"args\":[\"recipientmailedited@gmail.com\",{\"__class__\":\"Horde_Mime_Headers\"},{\"send8bit\":false,\"sep\":\"\\r\\n\",\"__class__\":\"Horde_Mail_Transport_Smtphorde\"}]},{\"file\":\"/var/www/nextcloud/apps/mail/lib/Service/MailTransmission.php\",\"line\":174,\"function\":\"send\",\"class\":\"Horde_Mime_Mail\",\"type\":\"->\",\"args\":[{\"send8bit\":false,\"sep\":\"\\r\\n\",\"__class__\":\"Horde_Mail_Transport_Smtphorde\"},false,false]},{\"file\":\"/var/www/nextcloud/apps/mail/lib/Controller/AccountsController.php\",\"line\":345,\"function\":\"sendMessage\",\"class\":\"OCA\\\\Mail\\\\Service\\\\MailTransmission\",\"type\":\"->\",\"args\":[{\"__class__\":\"OCA\\\\Mail\\\\Model\\\\NewMessageData\"},null,null,5]},{\"file\":\"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php\",\"line\":170,\"function\":\"send\",\"class\":\"OCA\\\\Mail\\\\Controller\\\\AccountsController\",\"type\":\"->\",\"args\":[3,\"sdfdsf\",\"\",\"recipientmailedited@gmail.com\",\"\",\"\",false,5,null,null,[],null]},{\"file\":\"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php\",\"line\":100,\"function\":\"executeController\",\"class\":\"OC\\\\AppFramework\\\\Http\\\\Dispatcher\",\"type\":\"->\",\"args\":[{\"__class__\":\"OCA\\\\Mail\\\\Controller\\\\AccountsController\"},\"send\"]},{\"file\":\"/var/www/nextcloud/lib/private/AppFramework/App.php\",\"line\":137,\"function\":\"dispatch\",\"class\":\"OC\\\\AppFramework\\\\Http\\\\Dispatcher\",\"type\":\"->\",\"args\":[{\"__class__\":\"OCA\\\\Mail\\\\Controller\\\\AccountsController\"},\"send\"]},{\"file\":\"/var/www/nextcloud/lib/private/AppFramework/Routing/RouteActionHandler.php\",\"line\":47,\"function\":\"main\",\"class\":\"OC\\\\AppFramework\\\\App\",\"type\":\"::\",\"args\":[\"OCA\\\\Mail\\\\Controller\\\\AccountsController\",\"send\",{\"__class__\":\"OC\\\\AppFramework\\\\DependencyInjection\\\\DIContainer\"},{\"accountId\":\"3\",\"_route\":\"mail.accounts.send\"}]},{\"function\":\"__invoke\",\"class\":\"OC\\\\AppFramework\\\\Routing\\\\RouteActionHandler\",\"type\":\"->\",\"args\":[{\"accountId\":\"3\",\"_route\":\"mail.accounts.send\"}]},{\"file\":\"/var/www/nextcloud/lib/private/Route/Router.php\",\"line\":297,\"function\":\"call_user_func\",\"args\":[{\"__class__\":\"OC\\\\AppFramework\\\\Routing\\\\RouteActionHandler\"},{\"accountId\":\"3\",\"_route\":\"mail.accounts.send\"}]},{\"file\":\"/var/www/nextcloud/lib/base.php\",\"line\":1007,\"function\":\"match\",\"class\":\"OC\\\\Route\\\\Router\",\"type\":\"->\",\"args\":[\"/apps/mail/api/accounts/3/send\"]},{\"file\":\"/var/www/nextcloud/index.php\",\"line\":37,\"function\":\"handleRequest\",\"class\":\"OC\",\"type\":\"::\",\"args\":[]}],\"File\":\"/var/www/nextcloud/apps/mail/vendor/pear-pear.horde.org/Horde_Mime/Horde/Mime/Part.php\",\"Line\":1642,\"Previous\":{\"Exception\":\"Horde_Mail_Exception\",\"Message\":\"Could not open secure TLS connection to the server.\",\"Code\":100,\"Trace\":[{\"file\":\"/var/www/nextcloud/apps/mail/vendor/pear-pear.horde.org/Horde_Mime/Horde/Mime/Part.php\",\"line\":1620,\"function\":\"send\",\"class\":\"Horde_Mail_Transport_Smtphorde\",\"type\":\"->\",\"args\":[\"recipientmailedited@gmail.com\",{\"From\":\"editedname <editedmailaddress.de>\",\"To\":\"recipientmailedited@gmail.com\",\"Cc\":\"\",\"Subject\":\"sdfdsf\",\"Message-ID\":\"<20200822144745.Horde.Q0qjPwozBVX8XyDSDyMgEsC@mail.example.com-edited>\",\"User-Agent\":\"Horde Application Framework 5\",\"Date\":\"Sat, 22 Aug 2020 14:47:45 +0000\",\"Content-Type\":\"text/plain; charset=utf-8\",\"MIME-Version\":\"1.0\"},null]},{\"file\":\"/var/www/nextcloud/apps/mail/vendor/pear-pear.horde.org/Horde_Mime/Horde/Mime/Mail.php\",\"line\":479,\"function\":\"send\",\"class\":\"Horde_Mime_Part\",\"type\":\"->\",\"args\":[\"recipientmailedited@gmail.com\",{\"__class__\":\"Horde_Mime_Headers\"},{\"send8bit\":false,\"sep\":\"\\r\\n\",\"__class__\":\"Horde_Mail_Transport_Smtphorde\"}]},{\"file\":\"/var/www/nextcloud/apps/mail/lib/Service/MailTransmission.php\",\"line\":174,\"function\":\"send\",\"class\":\"Horde_Mime_Mail\",\"type\":\"->\",\"args\":[{\"send8bit\":false,\"sep\":\"\\r\\n\",\"__class__\":\"Horde_Mail_Transport_Smtphorde\"},false,false]},{\"file\":\"/var/www/nextcloud/apps/mail/lib/Controller/AccountsController.php\",\"line\":345,\"function\":\"sendMessage\",\"class\":\"OCA\\\\Mail\\\\Service\\\\MailTransmission\",\"type\":\"->\",\"args\":[{\"__class__\":\"OCA\\\\Mail\\\\Model\\\\NewMessageData\"},null,null,5]},{\"file\":\"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php\",\"line\":170,\"function\":\"send\",\"class\":\"OCA\\\\Mail\\\\Controller\\\\AccountsController\",\"type\":\"->\",\"args\":[3,\"sdfdsf\",\"\",\"recipientmailedited@gmail.com\",\"\",\"\",false,5,null,null,[],null]},{\"file\":\"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php\",\"line\":100,\"function\":\"executeController\",\"class\":\"OC\\\\AppFramework\\\\Http\\\\Dispatcher\",\"type\":\"->\",\"args\":[{\"__class__\":\"OCA\\\\Mail\\\
edit2: в качестве обходного пути я мог подключиться к серверу smtp, заменив localhost на mail.example.com и используя аутентификацию STARTTLS.