我尝试通过这个 php 代码从 wampserver“localhost”发送电子邮件
<?php
$to = 'test1@gmail.com';
$subject = 'Fake sendmail test';
$message = 'If we can read this, it means that our fake Sendmail setup works!';
$headers = 'From: test2@gmail.com' . "\r\n" .
'Reply-To: eng.jirjawi@gmail.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if(mail($to, $subject, $message, $headers)) {
echo 'Email sent successfully!';
} else {
die('Failure: Email was not sent!');
}
?>
我使用了文件“sendmail”并将其放在文件“C:\wamp\sendmail”中,我将设置 sendmail.ini 文件更改为 -->
smtp_server=smtp.gmail.com
smtp_port=465
smtp_ssl=ssl
default_domain=localhost
error_logfile=error.log
auth_username=test2@gmail.com
auth_password=xxxxxxx
pop3_server=
pop3_username=
pop3_password=
force_sender=
force_recipient=
hostname=localhost
我更改了 C:\wamp\bin\apache\apache2.2.22\bin 中的设置 php.ini 文件,并将 C:\wamp\bin\php\php5.4.3 中的设置 php.ini 文件更改为
[mail function]
; For Win32 only.
; http://php.net/smtp
;SMTP =
; http://php.net/smtp-port
;smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = you@yourdomain
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = "C:\wamp\sendmail\sendmail.exe -t"
我更改了设置appach模块“SSL模块”检查
我更改了设置 php 扩展“php openssl”和“php sockets”
它不适用于代码没有发送电子邮件
在互联网上讨论了很多并尝试了很多方法为什么没有发生发射器以及正确的方法为错误道歉我的英语请帮助并谢谢