如何在托管 2 个域的服务器上指定传出 PHP 邮件的域


how can I specify the domain on outgoing PHP mail on a server hosting 2 domains?

我的服务器配置为example.net作为主机名,但 example.netdomain.com A 记录都指向 IP。

如果您访问domain.com其中一个页面会发送电子邮件。我试过这个

mail('my@email.com',
'an image (#' . $id . ') has been reported',
'an image (#' . $id . ') has been reported',
'From: reports@domain.com' . "'r'n" . 'Reply-To: reports@domain.com' . "'r'n" .
'Return-Path: reports@domain.com');

当将其发送到我的Live/Hotmail地址时,它会被发送到垃圾邮件文件夹,这就是message source显示的内容

Authentication-Results: hotmail.com;
spf=none (sender IP is *.*.*.*) smtp.mailfrom=www-data@example.net;
dkim=none header.d=domain.com;
x-hmca=none header.id=reports@domain.com
From: reports@domain.com
Reply-To: reports@domain.com
Return-Path: www-data@example.net

如果您在 *nix 服务器上,使用 sendmail,那么您可以通过第五个参数向 sendmail 传递额外的参数来指定 SMTP 传输中使用的发件人,例如:

mail('my@email.com',
'an image (#' . $id . ') has been reported',
'an image (#' . $id . ') has been reported',
'From: reports@domain.com' . "'r'n" . 'Reply-To: reports@domain.com' . "'r'n" .
'Return-Path: reports@domain.com',
'-freports@domain.com');