微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在ubuntu中通过php脚本发送邮件

我试图通过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邮件中的任何电子邮件.是否有任何配置和安装我缺少?

任何帮助,将不胜感激

解决方法

在第一行中,日志具体说明:

我们的系统检测到此消息是550-5.7.1可能是未经请求的邮件.为减少发送到Gmail的垃圾邮件数量,550-5.7.1此邮件已被阻止.请访问550-5.7.1 http://support.google.com/mail/bin/answer.py?hl=zh-CN\u0026amp;answer=188131获取550 5.7.1更多信息. kr8si13914201pbc.32 – gsmtp(回复DATA命令的结尾))

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

如果确定不是,则将其传递到收件箱,如果是中等严重性,则将其路由到垃圾邮件文件夹.如果评级非常低,它会阻止邮件 – 就像你的情况一样.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐