см. предыдущий пост на эту тему Как работает почта в Авангарде (продолжение)
отправляем почту на Yandex сразу после установки sendmail:
Connecting to [127.0.0.1] via relay... 220 ubuntu.localdomain ESMTP Sendmail 8.14.3/8.14.3/Debian-9.2ubuntu1; Tue, 25 Jan 2011 12:14:47 -0800; (No UCE/UBE) logging access from: localhost(OK)-localhost [127.0.0.1] >>> EHLO ubuntu.localdomain 250-ubuntu.localdomain Hello localhost [127.0.0.1], pleased to meet you 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-EXPN 250-VERB 250-8BITMIME 250-SIZE 250-DSN 250-ETRN 250-AUTH DIGEST-MD5 CRAM-MD5 250-DELIVERBY 250 HELP >>> VERB 250 2.0.0 Verbose mode >>> MAIL From:<murat@ubuntu.localdomain> SIZE=77 AUTH=murat@ubuntu.localdomain 250 2.1.0 <murat@ubuntu.localdomain>... Sender ok >>> RCPT To:<-s@ubuntu.localdomain> >>> RCPT To:<cvx@yandex.ru> >>> DATA 550 5.1.1 <-s@ubuntu.localdomain>... User unknown 250 2.1.5 <cvx@yandex.ru>... Recipient ok 354 Enter mail, end with "." on a line by itself >>> . 050 <cvx@yandex.ru>... Connecting to mx.yandex.ru. via esmtp... 050 220 mxfront22.mail.yandex.net (Want to use Yandex.Mail for your domain? Visit http://pdd.yandex.ru) 050 >>> EHLO ubuntu.localdomain 050 250-mxfront22.mail.yandex.net 050 250-8BITMIME 050 250-PIPELINING 050 250-SIZE 42991616 050 250 ENHANCEDSTATUSCODES 050 >>> MAIL From:<murat@ubuntu.localdomain> SIZE=308 050 250 2.1.0 <murat@ubuntu.localdomain> ok 050 >>> RCPT To:<cvx@yandex.ru> 050 >>> DATA 050 250 2.1.5 <cvx@yandex.ru> recipient ok 050 354 Enter mail, end with "." on a line by itself 050 >>> . 050 250 2.0.0 Ok: queued on mxfront22.mail.yandex.net as EUQSBfhG-EUQ0a0jG 050 <cvx@yandex.ru>... Sent (Ok: queued on mxfront22.mail.yandex.net as EUQSBfhG-EUQ0a0jG) 250 2.0.0 p0PKEljG013567 Message accepted for delivery cvx@yandex.ru... Sent (p0PKEljG013567 Message accepted for delivery) /home/murat/dead.letter... Saved message in /home/murat/dead.letter Closing connection to [127.0.0.1] >>> QUIT 221 2.0.0 ubuntu.localdomain closing connection
всё ок, письмо дошло.
отправляем на soap@mail.spbnit.ru (sendmail -i -v soap@mail.spbnit.ru -s < body.txt):
Connecting to [127.0.0.1] via relay... 220 ubuntu.localdomain ESMTP Sendmail 8.14.3/8.14.3/Debian-9.2ubuntu1; Tue, 25 Jan 2011 12:25:28 -0800; (No UCE/UBE) logging access from: localhost(OK)-localhost [127.0.0.1] >>> EHLO ubuntu.localdomain 250-ubuntu.localdomain Hello localhost [127.0.0.1], pleased to meet you 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-EXPN 250-VERB 250-8BITMIME 250-SIZE 250-DSN 250-ETRN 250-AUTH DIGEST-MD5 CRAM-MD5 250-DELIVERBY 250 HELP >>> VERB 250 2.0.0 Verbose mode >>> MAIL From:<murat@ubuntu.localdomain> SIZE=77 AUTH=murat@ubuntu.localdomain 250 2.1.0 <murat@ubuntu.localdomain>... Sender ok >>> RCPT To:<-s@ubuntu.localdomain> >>> RCPT To:<soap@mail.spbnit.ru> >>> DATA 550 5.1.1 <-s@ubuntu.localdomain>... User unknown 250 2.1.5 <soap@mail.spbnit.ru>... Recipient ok 354 Enter mail, end with "." on a line by itself >>> . 050 <soap@mail.spbnit.ru>... Connecting to mx.spbnit.ru. via esmtp... 050 220 mx.spbnit.ru ESMTP Postfix 050 >>> EHLO ubuntu.localdomain 050 250-mx.spbnit.ru 050 250-PIPELINING 050 250-SIZE 10240000 050 250-ETRN 050 250-ENHANCEDSTATUSCODES 050 250-8BITMIME 050 250 DSN 050 >>> MAIL From:<murat@ubuntu.localdomain> SIZE=308 050 250 2.1.0 Ok 050 >>> RCPT To:<soap@mail.spbnit.ru> 050 >>> DATA 050 550 5.1.8 <murat@ubuntu.localdomain>: Sender address rejected: Domain not found 050 554 5.5.1 Error: no valid recipients 050 >>> RSET 050 250 2.0.0 Ok 050 <murat@ubuntu.localdomain>... Connecting to local... 050 <murat@ubuntu.localdomain>... Sent 250 2.0.0 p0PKPSfP013665 Message accepted for delivery soap@mail.spbnit.ru... Sent (p0PKPSfP013665 Message accepted for delivery) /home/murat/dead.letter... Saved message in /home/murat/dead.letter Closing connection to [127.0.0.1] >>> QUIT 221 2.0.0 ubuntu.localdomain closing connection
говорит, что «Sender address rejected: Domain not found», меняем /etc/hosts:
127.0.0.1 localhost 127.0.1.1 beauty-exclusive.ru ubuntu.localdomain ubuntu # The following lines are desirable for IPv6 capable hosts ::1 localhost ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters
, получается следующее:
Connecting to [127.0.0.1] via relay... 220 ubuntu.localdomain ESMTP Sendmail 8.14.3/8.14.3/Debian-9.2ubuntu1; Tue, 25 Jan 2011 12:31:34 -0800; (No UCE/UBE) logging access from: localhost(OK)-localhost [127.0.0.1] >>> EHLO beauty-exclusive.ru 250-ubuntu.localdomain Hello localhost [127.0.0.1], pleased to meet you 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-EXPN 250-VERB 250-8BITMIME 250-SIZE 250-DSN 250-ETRN 250-AUTH DIGEST-MD5 CRAM-MD5 250-DELIVERBY 250 HELP >>> VERB 250 2.0.0 Verbose mode >>> MAIL From:<murat@beauty-exclusive.ru> SIZE=77 AUTH=murat@beauty-exclusive.ru 250 2.1.0 <murat@beauty-exclusive.ru>... Sender ok >>> RCPT To:<-s@beauty-exclusive.ru> >>> RCPT To:<soap@mail.spbnit.ru> >>> DATA 250 2.1.5 <-s@beauty-exclusive.ru>... Recipient ok 250 2.1.5 <soap@mail.spbnit.ru>... Recipient ok 354 Enter mail, end with "." on a line by itself >>> . 050 <-s@beauty-exclusive.ru>... Connecting to aspmx.l.google.com. via esmtp... 050 220 mx.google.com ESMTP q18si34332410eeh.46 050 >>> EHLO ubuntu.localdomain 050 250-mx.google.com at your service, [91.122.53.161] 050 250-SIZE 35651584 050 250-8BITMIME 050 250-STARTTLS 050 250 ENHANCEDSTATUSCODES 050 >>> STARTTLS 050 220 2.0.0 Ready to start TLS 050 >>> EHLO ubuntu.localdomain 050 250-mx.google.com at your service, [91.122.53.161] 050 250-SIZE 35651584 050 250-8BITMIME 050 250 ENHANCEDSTATUSCODES 050 >>> MAIL From:<murat@beauty-exclusive.ru> SIZE=310 050 250 2.1.0 OK q18si34332410eeh.46 050 >>> RCPT To:<-s@beauty-exclusive.ru> 050 550-5.1.1 The email account that you tried to reach does not exist. Please try 050 550-5.1.1 double-checking the recipient's email address for typos or 050 550-5.1.1 unnecessary spaces. Learn more at 050 550 5.1.1 http://mail.google.com/support/bin/answer.py?answer=6596 q18si34332410eeh.46 050 >>> DATA 050 503 5.5.1 RCPT first. q18si34332410eeh.46 050 >>> RSET 050 250 2.1.5 Flushed q18si34332410eeh.46 050 <soap@mail.spbnit.ru>... Connecting to mx.spbnit.ru. via esmtp... 050 220 mx.spbnit.ru ESMTP Postfix 050 >>> EHLO ubuntu.localdomain 050 250-mx.spbnit.ru 050 250-PIPELINING 050 250-SIZE 10240000 050 250-ETRN 050 250-ENHANCEDSTATUSCODES 050 250-8BITMIME 050 250 DSN 050 >>> MAIL From:<murat@beauty-exclusive.ru> SIZE=310 050 250 2.1.0 Ok 050 >>> RCPT To:<soap@mail.spbnit.ru> 050 >>> DATA 050 450 4.2.0 <soap@mail.spbnit.ru>: Recipient address rejected: Your host in Greylist. Try again later. 050 <soap@mail.spbnit.ru>... Deferred: 450 4.2.0 <soap@mail.spbnit.ru>: Recipient address rejected: Your host in Greylist. Try again later. 050 554 5.5.1 Error: no valid recipients 050 >>> RSET 050 250 2.0.0 Ok 050 >>> RSET 050 250 2.1.5 Flushed q18si34332410eeh.46 050 <murat@beauty-exclusive.ru>... Using cached ESMTP connection to aspmx.l.google.com. via esmtp... 050 >>> MAIL From:<> 050 250 2.1.0 OK q18si34332410eeh.46 050 >>> RCPT To:<murat@beauty-exclusive.ru> 050 550-5.1.1 The email account that you tried to reach does not exist. Please try 050 550-5.1.1 double-checking the recipient's email address for typos or 050 550-5.1.1 unnecessary spaces. Learn more at 050 550 5.1.1 http://mail.google.com/support/bin/answer.py?answer=6596 q18si34332410eeh.46 050 >>> DATA 050 503 5.5.1 RCPT first. q18si34332410eeh.46 050 >>> RSET 050 250 2.1.5 Flushed q18si34332410eeh.46 050 MAILER-DAEMON... aliased to postmaster 050 postmaster... aliased to root 050 postmaster... aliased to root 050 root... Connecting to local... 050 root... Sent 250 2.0.0 p0PKVY2Y013702 Message accepted for delivery -s,soap@mail.spbnit.ru... Sent (p0PKVY2Y013702 Message accepted for delivery) Closing connection to [127.0.0.1] >>> QUIT 221 2.0.0 ubuntu.localdomain closing connection
не очень понятно, на что он ругается и что за Greylist такой, но если просто прописать смарт хост, то всё будет нормально:
dnl # dnl # If you're on a dialup link, you should enable this - so sendmail dnl # will not bring up the link (it will queue mail for later) dnl define(`confCON_EXPENSIVE',`True')dnl dnl # dnl # Dialup/LAN connection overrides dnl # define(`SMART_HOST',`smtp.spbtlg.ru')dnl include(`/etc/mail/m4/dialup.m4')dnl include(`/etc/mail/m4/provider.m4')dnl dnl # dnl # Default Mailer setup MAILER_DEFINITIONS MAILER(`local')dnl MAILER(`smtp')dnl
посылаем письмо из под юзера dev, чтобы From Address был dev@beauty-exclusive.ru:
Connecting to [127.0.0.1] via relay... 220 beauty-exclusive.ru ESMTP Sendmail 8.14.3/8.14.3/Debian-9.2ubuntu1; Tue, 25 Jan 2011 13:21:05 -0800; (No UCE/UBE) logging access from: localhost(OK)-localho st [127.0.0.1] >>> EHLO beauty-exclusive.ru 250-beauty-exclusive.ru Hello localhost [127.0.0.1], pleased to meet you 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-EXPN 250-VERB 250-8BITMIME 250-SIZE 250-DSN 250-ETRN 250-AUTH DIGEST-MD5 CRAM-MD5 250-DELIVERBY 250 HELP >>> VERB 250 2.0.0 Verbose mode >>> MAIL From:<dev@beauty-exclusive.ru> SIZE=85 AUTH=dev@beauty-exclusive.ru 250 2.1.0 <dev@beauty-exclusive.ru>... Sender ok >>> RCPT To:<-s@beauty-exclusive.ru> >>> RCPT To:<soap@mail.spbnit.ru> >>> DATA 550 5.1.1 <-s@beauty-exclusive.ru>... User unknown 250 2.1.5 <soap@mail.spbnit.ru>... Recipient ok 354 Enter mail, end with "." on a line by itself >>> . 050 <soap@mail.spbnit.ru>... Connecting to smtp.spbtlg.ru. via relay... 050 220 smtp.spbtlg.ru ESMTP Postfix 050 >>> EHLO beauty-exclusive.ru 050 250-smtp.spbtlg.ru 050 250-PIPELINING 050 250-SIZE 10240000 050 250-VRFY 050 250-ETRN 050 250-ENHANCEDSTATUSCODES 050 250-8BITMIME 050 250 DSN 050 >>> MAIL From:<dev@beauty-exclusive.ru> SIZE=316 050 250 2.1.0 Ok 050 >>> RCPT To:<soap@mail.spbnit.ru> 050 >>> DATA 050 250 2.1.5 Ok 050 354 End data with <CR><LF>.<CR><LF> 050 >>> . 050 250 2.0.0 Ok: queued as EEACAC84DF 050 <soap@mail.spbnit.ru>... Sent (Ok: queued as EEACAC84DF) 250 2.0.0 p0PLL5P6014899 Message accepted for delivery soap@mail.spbnit.ru... Sent (p0PLL5P6014899 Message accepted for delivery) /home/dev/dead.letter... Saved message in /home/dev/dead.letter Closing connection to [127.0.0.1] >>> QUIT 221 2.0.0 beauty-exclusive.ru closing connection
письмо доходит и в логе нет ошибок.
такое тоже нормально работает независимо от /etc/hosts:
sendmail -oi -v -f from@gmail.com -t to@yandex.ru < body.txt
чтобы не было undisclosed-recipients надо в body.txt прописывать To:
Subject: test mail QQ
From: Me <test@gmail.com>
To: Vasya<test@yandex.ru>
first line of my message
Комментарий by Василий — 7 февраля 2011 @ 21:49
если в /etc/php5/apache2/php.ini прописать вот такую штуку:
; For Unix only. You may supply arguments as well (default: «sendmail -t -i»).
sendmail_path = /usr/sbin/sendmail -t -i -f somevalidaddress@gmail.com
то PHP mail() должно работать.
Комментарий by Василий — 7 февраля 2011 @ 22:34
скрипт для посылки письма:
<?php
$to = «testto@yandex.ru»;
$subject = «Hi!»;
$body = «Hi,\n\nHow are you? QQww`!»;
$from = ‘testfrom@gmail.com’;
if (mail($to, $subject, $body, «From: $from»)) {
echo(«<p>Message successfully sent!</p>»);
} else {
echo(«<p>Message delivery failed…</p>»);
}
?>
Комментарий by Профессор — 7 февраля 2011 @ 22:36
да, действительно в php.ini надо прописывать вот так:
sendmail_path = «/usr/sbin/sendmail -t -f myaddress@gmail.com -i»
иначе не работает
Комментарий by Федор — 16 мая 2011 @ 14:31