繁体   English   中英

从localhost发送电子邮件,而无需使用GMAIL邮件服务器在PHP中运行XAMMP

[英]Send email from localhost without running XAMMP in PHP using GMAIL mail server

我没有使用xammp,而是使用了“ fake sendmail for windows”。

使用“ sendmail.ini”的此设置

'[Modify] the php.ini file to use it (commented out the other lines):

'[mail function]
'; For Win32 only.
'; SMTP = smtp.gmail.com
'; smtp_port = 25

'; For Win32 only.
'; sendmail_from = <e-mail username>@gmail.com

'; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
'sendmail_path = "C:\xampp\sendmail\sendmail.exe -t"

以及php.ini的此设置

[sendmail]

smtp_server=smtp.gmail.com
smtp_port=25
error_logfile=error.log
debug_logfile=debug.log
auth_username=<username>
auth_password=<password>
force_sender=<e-mail username>@gmail.com'

但是我仍然反对这个错误

'Warning: mail(): SMTP server response: 421-4.7.0 [14.200.59.18 15] Our      system has detected that this message is 421-4.7.0 suspicious due to the very low reputation of the sending IP address. 421-4.7.0 To protect our users from spam, mail sent from your IP address has 421-4.7.0 been temporarily rate limited. Please visit 421 4.7.0 https://support.google.com/mail/answer/188131 for more information. c185si2211020itg.117 - gsmtp in C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\introducingphp\Code Work php\testmail.php on line 10
Check your email now....'

我的testmail.php代码是:

<?php
ini_set("SMTP", "aspmx.l.google.com");
ini_set("sendmail_from", "my_email@gmail.com");

$message = "The mail message was sent with the following mail     setting:\r\nSMTP = aspmx.l.google.com\r\nsmtp_port = 25\r\nsendmail_from = my_email@gmail.com";

$headers = "From:my_email@gmail.com";


mail("to_email@yahoo.com", "Testing", $message, $headers);
echo "Check your email now....<BR/>";
?>

这是电子邮件发送这么简单的不幸的副作用-任何人都可以按照您的方式编写代码并开始发送电子邮件。 尽管您的意图很可能是纯粹的,但是是什么阻止您循环运行代码,向成千上万个字母和数字的组合发送成千上万的消息,以@ gmail.com结尾?

垃圾邮件过滤器就是这样。 根据错误消息https://support.google.com/mail/answer/188131提供的链接,很明显Google认为您的服务器(实际上只是台式机,我认为是个人的)互联网连接)符合其准则( https://support.google.com/mail/answer/81126?hl=zh_CN )。 您当然可以在家里设置诸如静态IP之类的内容,以提高IP地址的声誉,并遵循所有Google准则...但是,使用网络托管公司的服务器运行代码可能要容易得多。

另一个选择是,如果您已经在网络主机上设置了域名,则不直接将电子邮件发送到Gmail-也许发送到限制较少的邮件服务器。 这样,您可以确定将收到消息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM