我是新的PHP。我试图使用此代码从PHP发送邮件。php从本地主机发送邮件
<?php
$to = '[email protected]';
$subject = 'The subject';
$message = 'hello';
$headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
我在php.ini
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = [email protected]
&在sendmail.ini
# A freemail service example
account Gmail
tls on
tls_certcheck off
host smtp.gmail.com
from [email protected]
auth on
user [email protected]
password xxxxxxxxx
# Set a default account
account default : Gmail
更改设置现在的代码成功运行,但我没有收到任何邮件。
您必须在本地主机上安装邮件服务器。 [PHPMailer](http://sourceforge.net/projects/phpmailer/) – Bora
@Bora:我认为可以添加Gmail或雅虎smtp邮件服务器。不是吗? –
或使用远程SMTP服务器,如GMAIL – 2013-08-17 11:00:16