从本地主机发送电子邮件,而不使用GMAIL邮件服务器在PHP中运行XAMMP

时间:2016-07-08 13:00:08

标签: php email

我没有使用xammp,而是使用"假的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/>";
?>

1 个答案:

答案 0 :(得分:0)

这是电子邮件易于发送的一个令人遗憾的副作用 - 任何人都可以按照您的方式编写代码并开始发送电子邮件。虽然你的意图很可能是纯粹的,但是阻止你在一个循环中运行你的代码,向每个字母和数字组合发送成千上万条消息,以@ gmail.com结尾?

垃圾邮件过滤器,这是什么。根据错误消息https://support.google.com/mail/answer/188131提供的链接,很明显Google并不认为您的服务器(实际上只是桌面,我假设在个人互联网连接上)符合要求他们的指导方针(https://support.google.com/mail/answer/81126?hl=en)。您当然可以将静态IP等内容设置到您的家中,以尝试提高IP地址的声誉,并遵循所有Google准则......但它可能更容易使用webhosting公司的服务器来运行您的代码。

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