简体   繁体   English

无法将电子邮件发送到我自己的域

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

I've set up sendmail on my ubuntu server and I have the following PHP code set up to email my own domain contact@example.com : 我已经在我的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);

However, the email never arrives. 但是,电子邮件永远不会到达。 However, when I change the destination email to Gmail or Yahoo, the email sends just fine. 但是,当我将目标电子邮件更改为Gmail或Yahoo时,该电子邮件发送就很好了。

This is the output of my mail.log file: 这是我的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.

The main issue I see in the error log is Deferred: Connection refused by mail.example.com , but I'm not sure what's wrong. 我在错误日志中看到的主要问题是Deferred: Connection refused by mail.example.com ,但是我不确定这是怎么回事。

you need to change config of postfix 您需要更改后缀的配置

vim /etc/postfix/main.cf

and remove your domain name from mydestination 's value 并从mydestination的值中删除您的域名

You need to add an entry for the loopback ip: 您需要为回送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