我的 sSMTP 设置有问题。它可以正常发送电子邮件,我正在接收它们,但它完全忽略了我的“发件人:”标题!如果通过 php 邮件功能触发 sSMPT,则发件人地址始终为“http@mydomain.com”,如果通过以 root 身份登录的 ssh 会话触发,则发件人地址始终为“http@mydomain.com”。所以我认为它总是使用当前用户并将其用作“发件人:”地址。
现在我知道您可以设置FromLineOverride=YES
为允许使用您自己的发件人地址,我已经在我的 sSMPT 配置中设置了它,但这不起作用。它只是完全忽略了这一点。
这是我的设置:
sSMTP 配置:
# The user that gets all the mails (UID < 1000, usually the admin)
root=info@mydomain.com
# The mail server (where the mail is sent to), both port 465 or 587 should be acceptable
mailhub=mydomain.com:587
# The address where the mail appears to come from for user authentication.
# rewriteDomain=info@mydomain.com
# i have tried this function above in different ways, doesnt change anything...
# The full hostname
hostname=mydomain.com
# Use SSL/TLS before starting negotiation
UseTLS=Yes
UseSTARTTLS=Yes
# Username/Password
AuthUser=info
AuthPass=password
# Email 'From header's can override the default domain?
FromLineOverride=YES
php 脚本来测试邮件功能:
<?PHP
$empfaenger = "user@gmail.com";
$betreff = "Testing Mailserver";
$text = "It seems to work";
$extra = "From:Info <info@mydomain.com>\r\n";
// i have tried "From: Info..." with a space inbetween From: and Info.
if(mail($empfaenger, $betreff, $text, $extra)) {
echo 'E-Mail sent';
}
?>
所以我没有收到任何错误,邮件通过了,邮件服务器在我的本地机器上运行并看到邮件,我可以确认邮件服务器没有更改它发送的地址,他只是从 sSMTP 获取他得到的东西。
我究竟做错了什么?
干杯
编辑:按照 DannySMc 的建议尝试了以下操作
<?PHP
$empfaenger = "user@gmail.com";
$betreff = "Testing Mailserver";
$text = "Seems to work";
$extra = "From: no-reply@example.com \r\n".
'Reply-To: no-reply@example.com '."\r\n" .
"Return-Path: no-reply@example.com\r\n" .
'X-Mailer: PHP/' . phpversion();
if(mail($empfaenger, $betreff, $text, $extra)) {
echo 'E-Mail versendet';
}
?>
还是不行。我仍然看到来自 http@mydomain.com 的邮件