簡體   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