【发布时间】:2014-03-06 16:58:09
【问题描述】:
我无法使用 php 脚本从本地主机发送电子邮件 这是我的代码
<?php
ini_set("SMTP","bhoi@gmail.com");
ini_set("smtp_port","25");
ini_set('sendmail_from', 'bhoi@gmail.com');
//define the receiver of the email
$to = 'deepan@gmail.com';
//define the subject of the email
$subject = 'Test email';
//define the message to be sent. Each line should be separated with \n
$message = "Hello World!\n\nThis is my first mail.";
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: bhoi@gmail.com\r\nReply-To: bhoi@gmail.com";
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
echo $mail_sent ? "Mail sent" : "Mail failed";
?>
php.ini 文件...
[邮件功能]
;仅适用于 Win32。
SMTP = 本地主机
smtp_port = 25
;仅适用于 Win32。
sendmail_from =bhoi@gmail.com
输出是“邮件失败”
请帮我解决我的问题。
【问题讨论】:
-
我怀疑
bhoi.test@gmail是一个 smtp 服务器
标签: php