简体   繁体   English

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

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

I am not using xammp but use the "fake sendmail for windows" . 我没有使用xammp,而是使用了“ fake sendmail for windows”。

with this setting for "sendmail.ini" 使用“ 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"

and this setting for php.ini 以及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'

but still I opposite to this Error 但是我仍然反对这个错误

'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....'

my testmail.php code is: 我的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/>";
?>

This is an unfortunate side-effect of email being so easy to send - anyone can write code the way you have and start sending out emails. 这是电子邮件发送这么简单的不幸的副作用-任何人都可以按照您的方式编写代码并开始发送电子邮件。 While your intentions are most likely pure, what's to stop you from running your code in a loop, sending thousands upon thousands of messages to every combination of letters and numbers, ending in @gmail.com? 尽管您的意图很可能是纯粹的,但是是什么阻止您循环运行代码,向成千上万个字母和数字的组合发送成千上万的消息,以@ gmail.com结尾?

The spam filter, that's what. 垃圾邮件过滤器就是这样。 Based on the link provided by the error message, https://support.google.com/mail/answer/188131 , it's clear that Google doesn't think that your server (which is actually just a desktop, I assume on a personal internet connection) meets their guidelines ( https://support.google.com/mail/answer/81126?hl=en ). 根据错误消息https://support.google.com/mail/answer/188131提供的链接,很明显Google认为您的服务器(实际上只是台式机,我认为是个人的)互联网连接)符合其准则( https://support.google.com/mail/answer/81126?hl=zh_CN )。 You can certainly set something up like static IP to your home in an attempt to increase the IP address's reputation, as well as following all of the Google guidelines...but it's probably far easier to use a webhosting company's server to run your code. 您当然可以在家里设置诸如静态IP之类的内容,以提高IP地址的声誉,并遵循所有Google准则...但是,使用网络托管公司的服务器运行代码可能要容易得多。

Another option is to simply not send your emails to Gmail - perhaps to a less restrictive mailserver, if you have a domain name set up on a webhost already. 另一个选择是,如果您已经在网络主机上设置了域名,则不直接将电子邮件发送到Gmail-也许发送到限制较少的邮件服务器。 That way, you can be sure that you will receive the messages. 这样,您可以确定将收到消息。

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

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