简体   繁体   中英

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

with this setting for "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

[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:

<?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?

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

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. That way, you can be sure that you will receive the messages.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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