从外部smtp服务器发送电子邮件

时间:2013-04-07 01:26:38

标签: php smtp

我正在尝试使用下面的php脚本从外部服务器发送邮件:

<?php
$recipient="dwqchen@gmail.com"; 
$subject="Website to customer";
$message="Customer Name: ".$_POST['name']."\r\n";
$message.="Customer Email: ".$_POST['email']."\r\n";
$message.="Customer Message: ".$_POST['msg']."\r\n"; 
$mailheader="From: <maria@comcast.net> \r\n";
$mailheader.="Reply to ".$_POST['email'];
mail($recipient, $subject, $message, $headers);
?>
<!DOCTYPE html>
<html>
<head>
<title>Sending mail from website to Customer</title>
</head>
<body>
<p>Thanks, <strong><?php echo $_POST['name']; ?></strong>, for your message.</p>
<p>Your email address: <strong><?php echo $_POST['email']; ?></strong></p>
<p>Your message: <br/><?php echo $_POST['msg']; ?></p>
</body>
<html>

我收到以下错误消息:

警告:mail()[function.mail]:“sendmail_from”未在php.ini中设置或自定义“From:”标头在C:\ Program Files(x86)\ Apache Software Foundation \ Apache2.2 \ htdocs中丢失第9行\ sendmail.php

我的php.ini设置为:

[mail function]
; For Win32 only.
SMTP = smtp.comcast.net
smtp_port = 25

; For Win32 only.
;sendmail_from = maria@comcast.net

有人能告诉我应该做什么吗?感谢。

0 个答案:

没有答案