从Windows服务器发送PHP邮件 [英] Sending PHP mail from Windows server
本文介绍了从Windows服务器发送PHP邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
function send_contact_form($ strName,$ strEmail,$ strPhone,$ strMessage)
{
$ to ='mymail@mysite.com';
$ subject ='从网站';
$ message ='< html lang =HE>
< head>
< title>
'。$ subject。'
< / title>
< / head>
< body style =text-align:right; direction:rtl; font-family:Arial;>
名称:'。$ strName。'< br>电子邮件:'
。$ strEmail。'< br>电话:'。$ strPhone
。'< br> br>消息:< br>'。$ strMessage。'
< / body>
< / html>';
$ email = $ strEmail;
$ header ='MIME-Version:1.0'。 \r\\\
;
$ header。='Content-type:text / html; charset = UTF-8'。 \r\\\
;
$ header。=From:$ email\r\\\
Reply-To:$ email。 \r\\\
;
mail($ to,$ subject,$ message,$ header);
}
解决方案
SMTP固定的Linux二进制sendmail(或替换)
您需要根据此页面,以便能够通过mail()函数发送电子邮件。
I have a form on my page. When the user hits the Send button - it's supposed to send an email with the details he entered in the form. Up until recently the form was hosted on a Linux server and I had no problem with it - the mail was sent and received. Recently I had to move to shared Windows server and since the move the mail is not sent. Here's the code that supposed to send the mail:
function send_contact_form($strName, $strEmail, $strPhone, $strMessage)
{
$to = 'mymail@mysite.com';
$subject = 'From the site';
$message = '<html lang="HE">
<head>
<title>
'.$subject.'
</title>
</head>
<body style="text-align:right; direction:rtl; font-family: Arial;">
Name: '.$strName.'<br>Email: '
.$strEmail.'<br>Phone: '.$strPhone
.'<br><br>Message: <br>'.$strMessage.'
</body>
</html>';
$email = $strEmail;
$header = 'MIME-Version: 1.0' . "\r\n";
$header .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
$header .= "From: $email\r\nReply-To: $email" . "\r\n";
mail($to, $subject, $message, $header);
}
解决方案
In a windows environment PHP uses SMTP insted of the Linux binary sendmail (or replacement)
You need to edit php.ini according to this page to be able to send e-mail via the mail() function.
这篇关于从Windows服务器发送PHP邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文