【问题标题】:Sending a mail via php script in ubuntu在 ubuntu 中通过 php 脚本发送邮件
【发布时间】:2014-07-27 05:30:39
【问题描述】:

我正在尝试通过 ubuntu 中的 php 脚本向我的 gmail id 发送邮件,但无法发送。 我的代码

<html>
<head><title>Send mail</title></head>
<body >


<?php
$name=$email=$query="";
if($_SERVER["REQUEST_METHOD"]=="POST"){
 $name = test_input($_POST["name"]);
   $email = test_input($_POST["email"]);
   $query = test_input($_POST["query"]);
 if(mail("abc@gmail.com","Subject",$query,"From: $email\n")){
 echo "email send";
}else{
echo "not send";
}
}
function test_input($data) {
   $data = trim($data);
   $data = stripslashes($data);
   $data = htmlspecialchars($data);
   return $data;
}
?>

<form method="post" action="<?php echo ($_SERVER["PHP_SELF"]);?>">
Name:<input type="text" name="name" required>


  Email id:<input type="email" name="email" required>
    Query:<textarea name="query" row="5" cols="40" required></textarea>

   <input type="submit" value="Submit">

    </form>

    </body>
</html>

我已经配置了我的 php.ini

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP=localhost
; http://php.net/smtp-port
smtp_port=25

; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = 

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path ="/usr/sbin/sendmail -t -i"

extension=php_openssl.dll //removed semicolon

输出 /var/log/mail.log

Jul 27 11:09:59 ak-VirtualBox postfix/smtp[5598]: 7069320869: to=<abc@gmail.com>, relay=gmail-smtp-in.l.google.com[74.125.129.26]:25, delay=4.9, delays=0.08/0.08/2.9/1.8, dsn=5.7.1, status=bounced (host gmail-smtp-in.l.google.com[74.125.129.26] said: 550-5.7.1 [14.98.28.24      12] Our system has detected that this message is 550-5.7.1 likely unsolicited mail. To reduce the amount of spam sent to Gmail, 550-5.7.1 this message has been blocked. Please visit 550-5.7.1 http://support.google.com/mail/bin/answer.py?hl=en&answer=188131 for 550 5.7.1 more information. kr8si13914201pbc.32 - gsmtp (in reply to end of DATA command))
Jul 27 11:09:59 ak-VirtualBox postfix/cleanup[5596]: 4AA162086D: message-id=<20140727053959.4AA162086D@ak-VirtualBox>
Jul 27 11:09:59 ak-VirtualBox postfix/qmgr[4781]: 4AA162086D: from=<>, size=2908, nrcpt=1 (queue active)
Jul 27 11:09:59 ak-VirtualBox postfix/bounce[5606]: 7069320869: sender non-delivery notification: 4AA162086D
Jul 27 11:09:59 ak-VirtualBox postfix/qmgr[4781]: 7069320869: removed
Jul 27 11:09:59 ak-VirtualBox postfix/local[5608]: 4AA162086D: to=<daemon@ak-VirtualBox>, relay=local, delay=0.12, delays=0.06/0.01/0/0.05, dsn=2.0.0, status=sent (delivered to mailbox)
Jul 27 11:09:59 ak-VirtualBox postfix/qmgr[4781]: 4AA162086D: removed

当我提交显示电子邮件发送的表单时(根据我的脚本),但我在我的 gmail id 中收到任何电子邮件。我是否缺少任何配置和安装?

任何帮助将不胜感激

【问题讨论】:

  • 您在/var/log/maillog 中看到了什么?并且..你已经用linux标记了这个问题并提到了Ubunto,但你的配置提到了php_openssl.dll。您还包括了仅限 Windows 和仅限 Unix 的 php.ini 邮件配置。您真正在运行什么操作系统?
  • 试试这样的smtp_port=465而不是25
  • @ghoti 更新了我的问题,我的虚拟机中安装了 ubuntu 14,安装在 Windows 8(主机)中
  • @SpencerX 仍然没有在我的收件箱中收到任何内容
  • 所以...您发布的日志的第一行似乎包含解释。

标签: php linux email


【解决方案1】:

在您的第一行中,日志特别说明:

Our system has detected that this message is 550-5.7.1 likely unsolicited mail. To reduce the amount of spam sent to Gmail, 550-5.7.1 this message has been blocked. Please visit 550-5.7.1 http://support.google.com/mail/bin/answer.py?hl=en&amp;answer=188131 for 550 5.7.1 more information. kr8si13914201pbc.32 - gsmtp (in reply to end of DATA command))

Gmail(和大多数其他邮件服务)使用发送域信誉、邮件传输/发送服务器的状态(列入黑名单等)、请求频率数、收件人数和邮件内容的组合来确定邮件是否为垃圾邮件.

如果确定不是,则将其发送到收件箱,在中等严重性的情况下,将其路由到垃圾邮件文件夹。如果评级真的很低,它会阻止邮件 - 就像你的情况一样。

【讨论】:

    【解决方案2】:

    您服务器上的 DNS 是否正确转发和反向?如果不是,这可以解释为什么来自您服务器的邮件被视为垃圾邮件。

    要查看您的邮件服务器是否存在会导致其他邮件服务器认为它是垃圾邮件发送者的明显问题,请尝试从您的邮件服务器向 check-auth@verifier.port25.com 发送消息。该服务将进行大量检查,您将收到包含大量信息的报告,例如您的邮件服务器的 DNS 是否设置正确,您的邮件服务器的 IP 是否在任何黑名单上,如果您有问题与您的 SPF 记录等。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-17
      • 1970-01-01
      • 2011-04-09
      • 2013-11-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多