Meccep45 Posted July 13, 2021 Posted July 13, 2021 пример системного файла msmtprc # A system wide configuration file is optional. # If it exists, it usually defines a default account. # This allows msmtp to be used like /opt/sbin/sendmail. account default # The SMTP smarthost host smtp.gmail.com # Use TLS on port 587 port 587 tls on tls_starttls on tls_trust_file /opt/etc/ssl/certs/ca-certificates.crt # Construct envelope-from addresses of the form "user@oursite.example" auth login user вася_пупкин@gmail.com passwordeval gpg --no-tty -q -d ~/.msmtp-password.gpg from %U@ваш.домен.ру # Syslog logging with facility LOG_MAIL instead of the default LOG_USER syslog LOG_MAIL aliases /opt/etc/aliases где переменная from %U@ваш.домен.ру. и есть Aliases где переменные типа так. # Aliases file # Send root and nobody root: root@ваш.домен.ru nobody: nobody@ваш.домен.ru # Send cron cron: cron@ваш.домен.ru # Send everything else to admin default: вася_пупкин@yandex.ru то есть поле from %U@ваш.домен.ру меняется от кого пришло письмо root@ваш.домен.ru или cron@ваш.домен.ru возможно я много хочу от программы. Quote
TheBB Posted July 13, 2021 Posted July 13, 2021 Для начала, поверить синтаксис конфигов (https://marlam.de/msmtp/msmtp.html) Quote
Meccep45 Posted July 13, 2021 Author Posted July 13, 2021 Скрытый текст # A system wide configuration file is optional. # If it exists, it usually defines a default account. # This allows msmtp to be used like /opt/sbin/sendmail. account default # The SMTP smarthost host smtp.gmail.com # Use TLS on port 587 port 587 tls on tls_starttls on tls_trust_file /opt/etc/ssl/certs/ca-certificates.crt # Construct envelope-from addresses of the form "user@oursite.example" auth login user вася_пупкин@gmail.com passwordeval gpg --no-tty -q -d ~/.msmtp-password.gpg from %U@доменное_имя # Syslog logging with facility LOG_MAIL instead of the default LOG_USER syslog LOG_MAIL почта уходит echo -e "Subject: Проверка темы почты\r\n\r\nЭто тестовое тело письма" | sendmail --debug -t петька_разбойник@yandex.ru Quote
Meccep45 Posted July 13, 2021 Author Posted July 13, 2021 Скрытый текст ~ # msmtp-runqueue.sh *** Sending 2021-07-13-11.15.54.mail to --debug -t петька_разбойник@yandex.ru ... loaded system configuration file /opt/etc/msmtprc loaded user configuration file /opt/root/.msmtprc falling back to default account using account default from /opt/etc/msmtprc host = smtp.gmail.com port = 587 source ip = (not set) proxy host = (not set) proxy port = 0 socket = (not set) timeout = off protocol = smtp domain = localhost auth = LOGIN user = вася_пупкин@gmail.com password = * passwordeval = gpg --no-tty -q -d ~/.msmtp-password.gpg ntlmdomain = (not set) tls = on tls_starttls = on tls_trust_file = /opt/etc/ssl/certs/ca-certificates.crt tls_crl_file = (not set) tls_fingerprint = (not set) tls_key_file = (not set) tls_cert_file = (not set) tls_certcheck = on tls_min_dh_prime_bits = (not set) tls_priorities = (not set) tls_host_override = (not set) auto_from = off maildomain = (not set) from = root@доменное_имя set_from_header = auto set_date_header = auto remove_bcc_headers = on undisclosed_recipients = off dsn_notify = (not set) dsn_return = (not set) logfile = (not set) logfile_time_format = (not set) syslog = LOG_MAIL aliases = (not set) reading recipients from the command line and the mail <-- 220 smtp.gmail.com ESMTP k12sm1406185lfv.14 - gsmtp --> EHLO localhost <-- 250-smtp.gmail.com at your service, [2a03:e2c0:16d2::2] <-- 250-SIZE 35882577 <-- 250-8BITMIME <-- 250-STARTTLS <-- 250-ENHANCEDSTATUSCODES <-- 250-PIPELINING <-- 250-CHUNKING <-- 250 SMTPUTF8 --> STARTTLS <-- 220 2.0.0 Ready to start TLS TLS session parameters: (TLS1.3)-(ECDHE-X25519)-(ECDSA-SECP256R1-SHA256)-(AES-256-GCM) TLS certificate information: Subject: C=US,ST=California,L=Mountain View,O=Google LLC,CN=smtp.gmail.com Issuer: C=US,O=Google Trust Services,CN=GTS CA 1O1 Validity: Activation time: Tue Jun 22 18:17:43 2021 Expiration time: Tue Sep 14 18:17:42 2021 Fingerprints: SHA256: 16:4A:CA:D8:99:2E:19:D1:7F:A5:C1:9F:90:36:3C:FD:1E:5D:BD:85:BC:EA:91:BC:CD:74:7C:0B:E5:21:D7:B9 SHA1 (deprecated): A9:31:AB:A6:01:E1:84:E9:26:27:02:5F:31:2D:73:C4:28:BF:90:B3 --> EHLO localhost <-- 250-smtp.gmail.com at your service, [] <-- 250-SIZE 35882577 <-- 250-8BITMIME <-- 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH <-- 250-ENHANCEDSTATUSCODES <-- 250-PIPELINING <-- 250-CHUNKING <-- 250 SMTPUTF8 --> AUTH LOGIN <-- 334 iippuiyycuvubipi --> gvbkbgvfcgfhjhbhbgvhgvvkk <-- 334 UGFzc3dvcmQ6 --> emtqZHJ5dHNqdnRmbWJrcA== <-- 235 2.7.0 Accepted --> MAIL FROM:<root@доменное_имя> --> RCPT TO:<петька_разбойник@yandex.ru> --> DATA <-- 250 2.1.0 OK k12sm1406185lfv.14 - gsmtp <-- 250 2.1.5 OK k12sm1406185lfv.14 - gsmtp <-- 354 Go ahead k12sm1406185lfv.14 - gsmtp --> From: root@доменное_имя --> Date: Tue, 13 Jul 2021 11:21:36 +0300 --> Subject: Проверка темы почты --> --> Это тестовое тело письма --> . <-- 250 2.0.0 OK 1626164469 k12sm1406185lfv.14 - gsmtp --> QUIT <-- 221 2.0.0 closing connection k12sm1406185lfv.14 - gsmtp 2021-07-13-11.15.54.mail sent successfully в поле вижу MAIL FROM:<root@доменное_имя> при получении undisclosed recipients вместо от root@доменное_имя. подозреваю надо включить undisclosed_recipients = off Quote
Meccep45 Posted August 4, 2021 Author Posted August 4, 2021 ~ # cat /opt/share/nginx/html/mail.php <?php if (mail('кому@отправить.ru', 'my subject', 'my message')){ echo 'отправленное'; }else{ echo 'неотправленное'; }; ?> ~ # ~ # php-cli /opt/share/nginx/html/mail.php отправленное ~ # открываю в браузере неотправленное. в обоих случаях в логе [04-Aug-2021 22:31:30 Europe/Moscow] mail() on [/opt/share/nginx/html/mail.php:2]: To: кому@отправить.ru -- Headers: -- Subject: my subject на что обратить внимание? Quote
Meccep45 Posted August 6, 2021 Author Posted August 6, 2021 от root работает в терминале, а от nobody не хочет. читал что файлу msmtprc права надо сменить 400, 640. не получилось. Quote
Meccep45 Posted August 6, 2021 Author Posted August 6, 2021 chown nobody:nobody /opt/etc/msmtprc тоже не помогло. Quote
Meccep45 Posted August 7, 2021 Author Posted August 7, 2021 msmtp only works at prompt, by nginx fastcgi php-fpm. почитал тут. так и не могу из веб браузера заставить работать. Quote
Meccep45 Posted August 7, 2021 Author Posted August 7, 2021 Web-сервер Nginx - пошагово в конце как раз про msmtp. цитата И тут мы подошли к моменту, который немного вынес мне мозг. ой как верно. Quote
Meccep45 Posted August 7, 2021 Author Posted August 7, 2021 всё мысли и действия закончились. права и пользователя менял. что msmtp ещё нужно, чтоб из веб работал. хоть бы ошибки были, так молчит партизан. Quote
Meccep45 Posted August 8, 2021 Author Posted August 8, 2021 PHP: функция mail() перечитал, попробовал. там как раз то что надо php-fpm. но из браузера так и не работает функция mail(). может кто протестирует тоже. это php 8.0.7-1 или msmtp не работает на entware. спасибо. Quote
TheBB Posted August 11, 2021 Posted August 11, 2021 Начал с "простого": ext-ui + php7 (осталось после тестов) ~ # opkg list-installed | grep ^php php7 - 7.4.20-1 php7-cgi - 7.4.20-1 php7-cli - 7.4.20-1 php7-mod-curl - 7.4.20-1 php7-mod-json - 7.4.20-1 php7-mod-session - 7.4.20-1 ~ # ~ # cat /opt/var/log/msmtp.log Aug 11 17:01:09 host=smtp.gmail.com tls=on auth=on user=xxx@gmail.com from=xxxo@gmail.com recipients=receipient@domain.com mailsize=178 smtpstatus=250 smtpmsg='250 2.0.0 OK 1628690470 g6sm27918641pfh.111 - gsmtp' exitcode=EX_OK ~ # Quote
Meccep45 Posted August 11, 2021 Author Posted August 11, 2021 Скрытый текст ~ # opkg list-installed | grep ^php php8 - 8.0.7-1 php8-cli - 8.0.7-1 php8-fpm - 8.0.7-1 php8-mod-bcmath - 8.0.7-1 php8-mod-calendar - 8.0.7-1 php8-mod-ctype - 8.0.7-1 php8-mod-curl - 8.0.7-1 php8-mod-dom - 8.0.7-1 php8-mod-exif - 8.0.7-1 php8-mod-fileinfo - 8.0.7-1 php8-mod-filter - 8.0.7-1 php8-mod-ftp - 8.0.7-1 php8-mod-gd - 8.0.7-1 php8-mod-gettext - 8.0.7-1 php8-mod-iconv - 8.0.7-1 php8-mod-intl - 8.0.7-1 php8-mod-mbstring - 8.0.7-1 php8-mod-mysqli - 8.0.7-1 php8-mod-mysqlnd - 8.0.7-1 php8-mod-opcache - 8.0.7-1 php8-mod-openssl - 8.0.7-1 php8-mod-pdo - 8.0.7-1 php8-mod-pdo-mysql - 8.0.7-1 php8-mod-phar - 8.0.7-1 php8-mod-session - 8.0.7-1 php8-mod-shmop - 8.0.7-1 php8-mod-simplexml - 8.0.7-1 php8-mod-sockets - 8.0.7-1 php8-mod-sqlite3 - 8.0.7-1 php8-mod-sysvmsg - 8.0.7-1 php8-mod-sysvsem - 8.0.7-1 php8-mod-sysvshm - 8.0.7-1 php8-mod-tokenizer - 8.0.7-1 php8-mod-xml - 8.0.7-1 php8-mod-xmlreader - 8.0.7-1 php8-mod-xmlwriter - 8.0.7-1 php8-mod-zip - 8.0.7-1 php7-cgi - 8.0.7-1 не ставил, подумал не нужен раз php8-fpm - 8.0.7-1 ставлю. Quote
TheBB Posted August 11, 2021 Posted August 11, 2021 Я проверил на минималке с текущей версией php. Чтоб проверить на php8 (fpm), его нужно собрать. Quote
TheBB Posted August 11, 2021 Posted August 11, 2021 php8-cgi ("Aug 11 19:03:41...") ~ # cat /opt/var/log/msmtp.log Aug 11 17:01:09 host=smtp.gmail.com tls=on auth=on user=xxx@gmail.com from=xxx@gmail.com recipients=receipient@domain.com mailsize=178 smtpstatus=250 smtpmsg='250 2.0.0 OK 1628690470 g6sm27918641pfh.111 - gsmtp' exitcode=EX_OK Aug 11 19:03:41 host=smtp.gmail.com tls=on auth=on user=xxx@gmail.com from=xxx@gmail.com recipients=receipient@domain.com mailsize=178 smtpstatus=250 smtpmsg='250 2.0.0 OK 1628697821 j4sm10528219pgi.6 - gsmtp' exitcode=EX_OK ~ # осталось с php8-fpm прогнать... ))) Quote
TheBB Posted August 11, 2021 Posted August 11, 2021 (edited) php8-fpm ("Aug 11 20:32:10...") ~ # cat /opt/var/log/msmtp.log Aug 11 17:01:09 host=smtp.gmail.com tls=on auth=on user=xxx@gmail.com from=xxx@gmail.com recipients=receipient@domain.com mailsize=178 smtpstatus=250 smtpmsg='250 2.0.0 OK 1628690470 g6sm27918641pfh.111 - gsmtp' exitcode=EX_OK Aug 11 19:03:41 host=smtp.gmail.com tls=on auth=on user=xxx@gmail.com from=xxx@gmail.com recipients=receipient@domain.com mailsize=178 smtpstatus=250 smtpmsg='250 2.0.0 OK 1628697821 j4sm10528219pgi.6 - gsmtp' exitcode=EX_OK Aug 11 19:17:12 host=smtp.gmail.com tls=on auth=on user=xxx@gmail.com from=xxx@gmail.com recipients=receipient@domain.com mailsize=178 smtpstatus=250 smtpmsg='250 2.0.0 OK 1628698632 d134sm28757018pfd.60 - gsmtp' exitcode=EX_OK Aug 11 20:32:10 host=smtp.gmail.com tls=on auth=on user=xxx@gmail.com from=xxx@gmail.com recipients=receipient@domain.com mailsize=178 smtpstatus=250 smtpmsg='250 2.0.0 OK 1628703130 c23sm5027pgb.74 - gsmtp' exitcode=EX_OK ~ # --- собсна, часть малявы из почтовика: This message was created automatically by mail delivery software. A message that you sent could not be delivered to one or more of its recipients. This is a permanent error. The following address(es) failed: receipient@domain.com The following text was generated during the delivery attempt: ------ receipient@domain.com ------ recipient does not have an account. Edited August 11, 2021 by TheBB add Quote
Meccep45 Posted August 11, 2021 Author Posted August 11, 2021 Скрытый текст <?php set_time_limit(15); error_reporting(E_ALL); ini_set('display_errors', 1); $result = mail('receipient@yandex.ru', 'my subject', 'my message'); echo '<pre>'; var_dump($result); echo '</pre>'; if ($result) { echo 'SUCCESS'; } else { echo 'ERROR'; } а у меня так. хнык. Quote
TheBB Posted August 11, 2021 Posted August 11, 2021 (edited) bool(true) SUCCESS Значок ошибки Адрес не найден Сообщение не доставлено, так как адрес receipient@yandex.ru не найден или не принимает входящие письма. Ответ удаленного сервера: 550 5.7.1 No such user! --- ~ # opkg list-installed | grep ^php php8 - 8.0.9-1 php8-cgi - 8.0.9-1 php8-fpm - 8.0.9-1 ~ # Edited August 11, 2021 by TheBB add Quote
Meccep45 Posted August 11, 2021 Author Posted August 11, 2021 если с терминала отравлю всё хорошо. ~ # php-cli /opt/share/nginx/html/mail.php <pre>bool(true) </pre>SUCCESS ~ # мистика. Quote
TheBB Posted August 11, 2021 Posted August 11, 2021 http://bin.entware.net/mipselsf-k3.4/test/php8/ перепроверить пути, права доступа, настройки... 1 Quote
Meccep45 Posted August 11, 2021 Author Posted August 11, 2021 Скрытый текст # A system wide configuration file is optional. # If it exists, it usually defines a default account. # This allows msmtp to be used like /opt/sbin/sendmail. account default # The SMTP smarthost host smtp.gmail.com # Use TLS on port 587 port 587 protocol smtp tls on tls_starttls on tls_trust_file /opt/etc/ssl/certs/ca-certificates.crt tls_certcheck on # Construct envelope-from addresses of the form "user@oursite.example" domain localhost auth login user vas@gmail.com passwordeval gpg --no-tty -q -d ~/.msmtp-password.gpg from %U@dom.jon.net # Syslog logging with facility LOG_MAIL instead of the default LOG_USER logfile /opt/var/log/php8/php-mail.log #syslog LOG_MAIL # Aliases file aliases /opt/etc/aliases chown nobody:nobody /opt/etc/msmtprc 600 Quote
Meccep45 Posted August 11, 2021 Author Posted August 11, 2021 php.ini Скрытый текст [mail function] ;SMTP = localhost ;smtp_port = 25 ;sendmail_from = me@example.com sendmail_path = "/opt/sbin/sendmail -t" ;mail.force_extra_parameters = mail.add_x_header = Off mail.log = "/opt/var/log/php8/php-mail.log" ;mail.log = syslog Quote
Meccep45 Posted August 11, 2021 Author Posted August 11, 2021 и симлинки ln -sf /opt/bin/msmtp-enqueue.sh /opt/sbin/sendmail ln -sf /opt/bin/msmtp-enqueue.sh /opt/lib/sendmail Quote
Meccep45 Posted August 11, 2021 Author Posted August 11, 2021 20 минут назад, TheBB сказал: http://bin.entware.net/mipselsf-k3.4/test/php8/ перепроверить пути, права доступа, настройки... пошёл пыхтеть. сомнения что без php8-cgi - 8.0.9-1 не работает. спасибо за тест. Quote
TheBB Posted August 12, 2021 Posted August 12, 2021 10 часов назад, Meccep45 сказал: сомнения что без php8-cgi - 8.0.9-1 не работает. Работает: ~ # opkg list-installed | grep ^php php8 - 8.0.9-1 php8-fpm - 8.0.9-1 ~ # ~ # cat /opt/var/log/msmtp.log Aug 11 17:01:09 host=smtp.gmail.com tls=on auth=on user=xxx@gmail.com from=xxx@gmail.com recipients=receipient@domain.com mailsize=178 smtpstatus=250 smtpmsg='250 2.0.0 OK 1628690470 g6sm27918641pfh.111 - gsmtp' exitcode=EX_OK Aug 11 19:03:41 host=smtp.gmail.com tls=on auth=on user=xxx@gmail.com from=xxx@gmail.com recipients=receipient@domain.com mailsize=178 smtpstatus=250 smtpmsg='250 2.0.0 OK 1628697821 j4sm10528219pgi.6 - gsmtp' exitcode=EX_OK Aug 11 19:17:12 host=smtp.gmail.com tls=on auth=on user=xxx@gmail.com from=xxx@gmail.com recipients=receipient@domain.com mailsize=178 smtpstatus=250 smtpmsg='250 2.0.0 OK 1628698632 d134sm28757018pfd.60 - gsmtp' exitcode=EX_OK Aug 11 20:32:10 host=smtp.gmail.com tls=on auth=on user=xxx@gmail.com from=xxx@gmail.com recipients=receipient@domain.com mailsize=178 smtpstatus=250 smtpmsg='250 2.0.0 OK 1628703130 c23sm5027pgb.74 - gsmtp' exitcode=EX_OK Aug 11 20:58:10 host=smtp.gmail.com tls=on auth=on user=xxx@gmail.com from=xxx@gmail.com recipients=receipient@yandex.ru mailsize=127 smtpstatus=250 smtpmsg='250 2.0.0 OK 1628704690 d10sm163604pfd.49 - gsmtp' exitcode=EX_OK Aug 12 08:30:23 host=smtp.gmail.com tls=on auth=on user=xxx@gmail.com from=xxx@gmail.com recipients=receipient@domain.com mailsize=178 smtpstatus=250 smtpmsg='250 2.0.0 OK 1628746223 x19sm1716878pgk.37 - gsmtp' exitcode=EX_OK Aug 12 08:30:36 host=smtp.gmail.com tls=on auth=on user=xxx@gmail.com from=xxx@gmail.com recipients=receipient@yandex.ru mailsize=127 smtpstatus=250 smtpmsg='250 2.0.0 OK 1628746237 i6sm1551555pfa.44 - gsmtp' exitcode=EX_OK ~ # "Aug 12 08:30:23..." ~ # cat /opt/share/www/msmtp.php <?php if(mail("receipient@domain.com","A Subject Here","Hi there,\nThis email was sent using PHP's mail function.")) print "Email successfully sent"; else print "An error occured"; ?> ~ # "Aug 12 08:30:36..." ~ # cat /opt/share/www/msmtp1.php <?php set_time_limit(15); error_reporting(E_ALL); ini_set('display_errors', 1); $result = mail('receipient@yandex.ru', 'my subject', 'my message'); echo '<pre>'; var_dump($result); echo '</pre>'; if ($result) { echo 'SUCCESS'; } else { echo 'ERROR'; } ~ # Quote
Meccep45 Posted August 12, 2021 Author Posted August 12, 2021 не понимаю почему у вас из браузера работает, а у меня только с терминала. где я ошибаюсь. Quote
TheBB Posted August 12, 2021 Posted August 12, 2021 А связка nginx+php-fpm работает? Проблема только с почтой? Quote
Meccep45 Posted August 12, 2021 Author Posted August 12, 2021 2 минуты назад, TheBB сказал: А связка nginx+php-fpm работает? Проблема только с почтой? nginx+php-fpm работает. тест почты именно через веб браузер не как не осилю. Quote
TheBB Posted August 12, 2021 Posted August 12, 2021 скидывайте конфиги в личку, персональные данные (адреса/явки/пароли) можете затереть , по наличию времени, будем посмотреть. Quote
Meccep45 Posted August 12, 2021 Author Posted August 12, 2021 отправил. если не доверять людям, тогда и не узнаешь порядочных людей. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.