我正在尝试使用PHP mail()
函数向用户发送表单电子邮件等。我无法指定不是用户的帐户,例如 noreply@myserver.com 我之前已经能够使用共享服务器(GoDaddy)。 PHP邮件已启用,但只在我使用user@mydomain.com时发送,这是我用来测试电子邮件的php:
<?php
$to = "myemail@gmail.com";
$header = "From: noreply@myserver.com";
$subject = "Test email";
$body = "Test Email,\n\nIt works!";
if (mail($to, $subject, $body, $header)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
?>
如果我将 user@myserver.com 替换为from,则无效,没有电子邮件。我确定有一个软件包或一些.conf文件我没有设置,但我搜索过,一无所获。
感谢您的帮助,
艾
---编辑---
最新的mail.log输出:
Aug 25 22:41:33 mywebsite sendmail[22978]: u7PMfWV7022978: to=myuser@gmail.com, ctladdr=www-data (33/33), delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=30123, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, sta$
Aug 25 22:41:33 mywebsite sendmail[22983]: u7PMfXXJ022983: from=www-data, size=123, class=0, nrcpts=1, msgid=<201608252241.u7PMfXXJ022983@mywebsite.io>, relay=www-data@localhost
Aug 25 22:41:33 mywebsite sm-mta[22984]: u7PMfXT3022984: from=<www-data@mywebsite.io>, size=330, class=0, nrcpts=1, msgid=<201608252241.u7PMfXXJ022983@mywebsite.io>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
Aug 25 22:41:33 mywebsite sendmail[22983]: u7PMfXXJ022983: to=myuser@gmail.com, ctladdr=www-data (33/33), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30123, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, sta$
Aug 25 22:41:33 mywebsite sendmail[22988]: u7PMfXSp022988: from=www-data, size=123, class=0, nrcpts=1, msgid=<201608252241.u7PMfXSp022988@mywebsite.io>, relay=www-data@localhost
Aug 25 22:41:33 mywebsite sm-mta[22989]: u7PMfXRe022989: from=<www-data@mywebsite.io>, size=330, class=0, nrcpts=1, msgid=<201608252241.u7PMfXSp022988@mywebsite.io>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
Aug 25 22:41:33 mywebsite sendmail[22988]: u7PMfXSp022988: to=myuser@gmail.com, ctladdr=www-data (33/33), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30123, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, sta$
Aug 25 22:41:33 mywebsite sm-mta[22981]: STARTTLS=client, relay=gmail-smtp-in.l.google.com., version=TLSv1.2, verify=FAIL, cipher=ECDHE-RSA-AES128-GCM-SHA256, bits=128/128
Aug 25 22:41:33 mywebsite sm-mta[22986]: STARTTLS=client, relay=gmail-smtp-in.l.google.com., version=TLSv1.2, verify=FAIL, cipher=ECDHE-RSA-AES128-GCM-SHA256, bits=128/128
Aug 25 22:41:33 mywebsite sendmail[22993]: u7PMfXuL022993: from=www-data, size=123, class=0, nrcpts=1, msgid=<201608252241.u7PMfXuL022993@mywebsite.io>, relay=www-data@localhost
Aug 25 22:41:33 mywebsite sm-mta[22991]: STARTTLS=client, relay=gmail-smtp-in.l.google.com., version=TLSv1.2, verify=FAIL, cipher=ECDHE-RSA-AES128-GCM-SHA256, bits=128/128
Aug 25 22:41:33 mywebsite sm-mta[22994]: u7PMfXjR022994: from=<www-data@mywebsite.io>, size=330, class=0, nrcpts=1, msgid=<201608252241.u7PMfXuL022993@mywebsite.io>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
Aug 25 22:41:33 mywebsite sendmail[22993]: u7PMfXuL022993: to=myuser@gmail.com, ctladdr=www-data (33/33), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30123, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, sta$
Aug 25 22:41:33 mywebsite sm-mta[22991]: u7PMfXRe022989: to=<myuser@gmail.com>, ctladdr=<www-data@mywebsite.io> (33/33), delay=00:00:00, xdelay=00:00:00, mailer=esmtp, pri=120330, relay=gmail-smtp-in.l.google.com. $
Aug 25 22:41:33 mywebsite sm-mta[22986]: u7PMfXT3022984: to=<myuser@gmail.com>, ctladdr=<www-data@mywebsite.io> (33/33), delay=00:00:00, xdelay=00:00:00, mailer=esmtp, pri=120330, relay=gmail-smtp-in.l.google.com. $
Aug 25 22:41:33 mywebsite sendmail[22998]: u7PMfXfL022998: from=www-data, size=123, class=0, nrcpts=1, msgid=<201608252241.u7PMfXfL022998@mywebsite.io>, relay=www-data@localhost
Aug 25 22:41:33 mywebsite sm-mta[22996]: STARTTLS=client, relay=gmail-smtp-in.l.google.com., version=TLSv1.2, verify=FAIL, cipher=ECDHE-RSA-AES128-GCM-SHA256, bits=128/128
Aug 25 22:41:33 mywebsite sm-mta[22999]: u7PMfXFp022999: from=<www-data@mywebsite.io>, size=330, class=0, nrcpts=1, msgid=<201608252241.u7PMfXfL022998@mywebsite.io>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
Aug 25 22:41:33 mywebsite sendmail[22998]: u7PMfXfL022998: to=myuser@gmail.com, ctladdr=www-data (33/33), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30123, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, sta$
Aug 25 22:41:34 mywebsite sm-mta[22981]: u7PMfWXO022979: to=<myuser@gmail.com>, ctladdr=<www-data@mywebsite.io> (33/33), delay=00:00:01, xdelay=00:00:01, mailer=esmtp, pri=120330, relay=gmail-smtp-in.l.google.com. $
Aug 25 22:41:34 mywebsite sm-mta[23001]: STARTTLS=client, relay=gmail-smtp-in.l.google.com., version=TLSv1.2, verify=FAIL, cipher=ECDHE-RSA-AES128-GCM-SHA256, bits=128/128
Aug 25 22:41:34 mywebsite sm-mta[22996]: u7PMfXjR022994: to=<myuser@gmail.com>, ctladdr=<www-data@mywebsite.io> (33/33), delay=00:00:01, xdelay=00:00:01, mailer=esmtp, pri=120330, relay=gmail-smtp-in.l.google.com. $
Aug 25 22:41:34 mywebsite sendmail[23003]: u7PMfY9M023003: from=www-data, size=123, class=0, nrcpts=1, msgid=<201608252241.u7PMfY9M023003@mywebsite.io>, relay=www-data@localhost
Aug 25 22:41:34 mywebsite sm-mta[23001]: u7PMfXFp022999: to=<myuser@gmail.com>, ctladdr=<www-data@mywebsite.io> (33/33), delay=00:00:01, xdelay=00:00:01, mailer=esmtp, pri=120330, relay=gmail-smtp-in.l.google.com. $
Aug 25 22:41:34 mywebsite sm-mta[23004]: u7PMfYXr023004: from=<www-data@mywebsite.io>, size=330, class=0, nrcpts=1, msgid=<201608252241.u7PMfY9M023003@mywebsite.io>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
Aug 25 22:41:34 mywebsite sendmail[23003]: u7PMfY9M023003: to=myuser@gmail.com, ctladdr=www-data (33/33), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30123, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, sta$
Aug 25 22:41:34 mywebsite sendmail[23008]: u7PMfYjs023008: from=www-data, size=123, class=0, nrcpts=1, msgid=<201608252241.u7PMfYjs023008@mywebsite.io>, relay=www-data@localhost
Aug 25 22:41:34 mywebsite sm-mta[23009]: u7PMfYPG023009: from=<www-data@mywebsite.io>, size=330, class=0, nrcpts=1, msgid=<201608252241.u7PMfYjs023008@mywebsite.io>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
Aug 25 22:41:34 mywebsite sendmail[23008]: u7PMfYjs023008: to=myuser@gmail.com, ctladdr=www-data (33/33), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30123, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, sta$
Aug 25 22:41:34 mywebsite sm-mta[23006]: STARTTLS=client, relay=gmail-smtp-in.l.google.com., version=TLSv1.2, verify=FAIL, cipher=ECDHE-RSA-AES128-GCM-SHA256, bits=128/128
Aug 25 22:41:34 mywebsite sendmail[23013]: u7PMfYZj023013: from=www-data, size=123, class=0, nrcpts=1, msgid=<201608252241.u7PMfYZj023013@mywebsite.io>, relay=www-data@localhost
Aug 25 22:41:34 mywebsite sm-mta[23011]: STARTTLS=client, relay=gmail-smtp-in.l.google.com., version=TLSv1.2, verify=FAIL, cipher=ECDHE-RSA-AES128-GCM-SHA256, bits=128/128
Aug 25 22:41:34 mywebsite sm-mta[23014]: u7PMfY77023014: from=<www-data@mywebsite.io>, size=330, class=0, nrcpts=1, msgid=<201608252241.u7PMfYZj023013@mywebsite.io>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
Aug 25 22:41:34 mywebsite sendmail[23013]: u7PMfYZj023013: to=myuser@gmail.com, ctladdr=www-data (33/33), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30123, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, sta$
Aug 25 22:41:34 mywebsite sm-mta[23006]: u7PMfYXr023004: to=<myuser@gmail.com>, ctladdr=<www-data@mywebsite.io> (33/33), delay=00:00:00, xdelay=00:00:00, mailer=esmtp, pri=120330, relay=gmail-smtp-in.l.google.com. $
Aug 25 22:41:34 mywebsite sm-mta[23016]: STARTTLS=client, relay=gmail-smtp-in.l.google.com., version=TLSv1.2, verify=FAIL, cipher=ECDHE-RSA-AES128-GCM-SHA256, bits=128/128
Aug 25 22:41:35 mywebsite sm-mta[23011]: u7PMfYPG023009: to=<myuser@gmail.com>, ctladdr=<www-data@mywebsite.io> (33/33), delay=00:00:01, xdelay=00:00:01, mailer=esmtp, pri=120330, relay=gmail-smtp-in.l.google.com. $
Aug 25 22:41:35 mywebsite sm-mta[23016]: u7PMfY77023014: to=<myuser@gmail.com>, ctladdr=<www-data@mywebsite.io> (33/33), delay=00:00:01, xdelay=00:00:01, mailer=esmtp, pri=120330, relay=gmail-smtp-in.l.google.com. $