0

我的 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 的邮件

4

3 回答 3

1

我无法解决这个问题。如果其他人遇到这个问题,你唯一可以尝试的是FromLineOverride=YES如果这不起作用,那么你就完蛋了。

我是其中之一,已经从 sSMTP 转换为常规的 sendmail,这就像一个魅力。

干杯

于 2015-03-10T22:11:47.593 回答
0

尝试以下将其添加到您的 php 脚本中:

$email_message = "Something here";
$email_subject = "a subject";
$email_recipient = "test@example.com";
$email_headers = "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();
mail($email_recipient, $email_subject, $email_message, $email_headers);
于 2015-03-09T14:49:31.107 回答
0

sSMTP 是一个流行的选择,作为 docker 容器中 php 邮件中继的简单 sendmail 替代品。如果有人遇到这个问题,因为他们使用 sMTP 和 Docker 容器,并且无法让 from 标头在 php 电子邮件中正确显示,那么我建议转移到 msmtp。它很容易在标准的 php docker 镜像中安装和使用。

于 2017-02-14T18:31:59.653 回答