我尝试从wampserver发送电子邮件“localhost”由这个php代码
<?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套接字”
并且它没有工作与代码没有发送电子邮件
讨论了很多在互联网上,并尝试了许多方法,为什么不发生发射机和什么正确的方式道歉的错误,我的英语请帮助,谢谢你
2条答案
按热度按时间dvtswwa31#
PHPMailer一直在开发服务器(本地主机)和实时网站上为我工作。
下载PHPMailerx 1 e1f1x,解压缩并将其放到应用程序的目录中。
当你想发送一封邮件时,使用下面的代码:
更新:您应该更新您的PHP安装,以使其正常工作。对于您得到的错误,请尝试以下操作:
在php.ini中搜索行
并移除;所以它变成了:
wb1gzix02#
这对我很有效: