问题在于:
mail($to, $subject, $content, $headers);
中的$headers
看看你是怎么写的?
有的网站可能将你的$headers误认为垃圾邮件而把邮件过滤掉了
试试仅
$headers = "From: <[email protected]>\r\n"; //[email protected]为你的发件地址
mail($to, $subject, $content, $headers);
中的$headers
看看你是怎么写的?
有的网站可能将你的$headers误认为垃圾邮件而把邮件过滤掉了
试试仅
$headers = "From: <[email protected]>\r\n"; //[email protected]为你的发件地址
欢迎各位高手再提意见
function socketmail($toArray, $subject, $message) {
$to = "[email protected]";
$to_name = "name";
$from = "[email protected]";
$from_name = "me";
$server_set = "sever";//公司邮件server.
ini_set(sendmail_from, $from); $connect = fsockopen ($server_set, "25", &$errno, &$errstr, 130) or die("Could not talk to the sendmail server!");
echo "<br>step1 : ".$rcv = fgets($connect, 1024);
fputs($connect, "HELO {$_SERVER['SERVER_NAME']}\r\n");
echo "<br>step2: ".$rcv = fgets($connect, 1024);
fputs($connect, "MAIL FROM:".$from."\r\n");
echo "<br>step3 : ".$rcv = fgets($connect, 1024);
fputs($connect, "RCPT TO:".$to."\r\n");
echo "<br>step4 : ".$rcv = fgets($connect, 1024);
fputs($connect, "DATA\r\n");
echo "<br>step5 : ".$rcv = fgets($connect, 1024);
fputs($connect, "Subject: $subject\r\n");
fputs($connect, "From: ".$from_name." <".$from.">\r\n");
fputs($connect, "To: ".$to_name." <".$to.">\r\n");
fputs($connect, "X-Sender: <".$from.">\r\n");
fputs($connect, "Return-Path: <".$from.">\r\n");
fputs($connect, "Errors-To: <".$from.">\r\n");
fputs($connect, "X-Mailer: PHP\r\n");
fputs($connect, "X-Priority: 3\r\n");
fputs($connect, "Content-Type:text/html; \nContent-Transfer-Encoding:7bit\r\n");
fputs($connect, "\r\n");
fputs($connect, stripslashes($message)." \r\n");
fputs($connect, ".\r\n");
echo "<br>step7 : ".$rcv = fgets($connect, 1024);
fputs($connect, "RSET\r\n");
echo "<br>step6 : ".$rcv = fgets($connect, 1024);
fputs ($connect, "QUIT\r\n");
echo "<br>step7 : ".$rcv = fgets ($connect, 1024);
fclose($connect);
ini_restore(sendmail_from);} $msg = "this is a test";socketmail("","testmail",$msg);?>
我试过把头改为"headers = "From: <[email protected]>\r\n"; //[email protected]为你的发件地址",还是不行.急啊,试一好几天都没有结果.
给你个mail()函数试试
<?php
$subject = "TEST";
$to = "[email protected]";
$subject = "test mail";
$content = "this is a test";
$headers = "From: yourname<[email protected]>\r\n";
$sendinfo = mail($to, $subject, $content, $headers);
?>
可以带身份认证或不带。文章写的很乱,记得当初整理相当累:
http://www.phpfans.net/forum/viewthread.php?tid=6