簡體   English   中英

無法將電子郵件發送到我自己的域

[英]Can't send email to my own domain

我已經在我的ubuntu服務器上設置了sendmail,並且設置了以下PHP代碼以通過電子郵件發送我自己的域contact@example.com

$subject = "Hello!";
$message = "This is a test.";

$header = "From: " . $email . "\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

mail("contact@example.com", $subject, $message, $header);

但是,電子郵件永遠不會到達。 但是,當我將目標電子郵件更改為Gmail或Yahoo時,該電子郵件發送就很好了。

這是我的mail.log文件的輸出:

Oct 24 16:41:17 CA2EXAMPLE01 sendmail[4476]: s9OGfHVe004476: from=www-data, size=186, class=0, nrcpts=1, msgid=<201410241641.s9OGfHVe004476@CA2EXAMPLE01.example.com>, relay=www-data@localhost
Oct 24 16:41:17 CA2EXAMPLE01 sm-mta[4477]: s9OGfHeD004477: from=<www-data@CA2EXAMPLE01.example.com>, size=431, class=0, nrcpts=1, msgid=<201410241641.s9OGfHVe004476@CA2EXAMPLE01.example.com>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
Oct 24 16:41:17 CA2EXAMPLE01 sendmail[4476]: s9OGfHVe004476: to=contact@example.com, ctladdr=www-data (33/33), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30186, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (s9OGfHeD004477 Message accepted for delivery)
Oct 24 16:41:17 CA2EXAMPLE01 sm-mta[4479]: s9OGfHeD004477: to=<contact@example.com>, ctladdr=<www-data@CA2EXAMPLE01.example.com> (33/33), delay=00:00:00, xdelay=00:00:00, mailer=esmtp, pri=120431, relay=mail.example.com. [11.23.41.55], dsn=4.0.0, stat=Deferred: Connection refused by mail.example.com.

我在錯誤日志中看到的主要問題是Deferred: Connection refused by mail.example.com ,但是我不確定這是怎么回事。

您需要更改后綴的配置

vim /etc/postfix/main.cf

並從mydestination的值中刪除您的域名

您需要為回送ip添加一個條目:

#add this to bind hostname
127.0.0.1      CA2EXAMPLE01.example.com//whatever you meant by mail.example.com

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM