My PHP code for sending mail
is:
$email_to="deepuskmr@gmail.com";
$email_subject="It works";
$email_message="Hello. I can send mail!";
$headers = "From:Dpu\r\n".
"Reply-To: sdeepu.kmr@gmail.com\r\n'" .
"X-Mailer: PHP/" . phpversion();
mail($email_to, $email_subject, $email_message, $headers);
echo "mail sent!"
But this code not sending email. It gives the error.
My php.ini file settings are
[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 = sdeepu.kmr@gmail.com
I am working in localhost
. And I am using windows 64
machine.
You are using localhost
as mail server, if you did not installed one (SMTP server), this will obviously returns you cannot connect.
You should have something like :
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.gmail.com
; http://php.net/smtp-port
smtp_port = 587
I use the free and awesome hMail on my dev box so that I can test my email functions and not just get mail() errors!
http://www.stylus.co.za/setting-up-hmail-on-your-development-box/
我已经在Fasthost上托管了一个站点,它是Windows服务器。出于安全原因,我们无法通过在Fasthosts平台中使用任意地址作为“发件人”地址来发送电子邮件,“发件人”地址必须是存在于邮箱中的邮箱。 Fasthosts平台。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.