在發送電子郵件的PHP腳本中存在一些問題(代碼如下)。基本上,它將存儲在sql數據庫中的聯繫人信息填充到vCard文件中,並使用php mail()函數將其附加到電子郵件中。未在新服務器上發送PHP郵件()函數
前幾天我曾在共享主機服務器上完美工作......但我最近將所有內容都遷移到了VPS,並且它神奇地停止了工作。 Mail()在發送時繼續返回true,但實際的電子郵件永遠不會到達我的收件箱。
//sendemail: emails a vCard when passed an email address and name
function sendemail($address, $scanreduser)
{
include('../dbconnect.php');
$info = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE usernum='". $usernum ."' LIMIT 1 "));
$vcard_content = "BEGIN:VCARD\r";
$vcard_content .= "VERSION:3.0\r";
$vcard_content .= "N:".$info[lname].";". $info[fname] .";;;\r";
$vcard_content .= "FN:".$info[fname]." ". $info[lname] ."\r";
$vcard_content .= "ORG:".$info[company].";\r";
$vcard_content .= "TITLE:".$info[title]."\r";
$vcard_content .= "EMAIL;type=INTERNET;type=WORK;type=pref:".$info[email]."\r";
$vcard_content .= "TEL;type=WORK;type=pref:".$info[phone]."\r";
$vcard_content .= "item2.URL;type=pref:".$info[website]."\r";
$vcard_content .= "item2.X-ABLabel:_$!<HomePage>!\$\_\r";
$vcard_content .= "X-ABShowAs:COMPANY\r";
$vcard_content .= "END:VCARD";
$email_subject = "Your vCard from " . $info[fname] . " " . $info[lname];
$fileatt_type = "application/octet-stream"; // File Type
$fileatt_name = $info[fname] ."_". $info[lname] .".vcf";
$headers = "From: [email protected]";
$today = date("l, F j, Y, g:i a");
$message = "<br />Simply open the attached vCard file to view/download the information<br />";
$message .= $today." PST<br /><br />";
$message .= $info[name]."<br />";
$data = $vcard_content;
$data = chunk_split(base64_encode($data));
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
$message .= "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type:text/html; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
echo @mail($address, $email_subject, $message, $headers);
echo $address;
}
新服務器是否有正確配置的SMTP服務器(sendmail,postfix,qmail等)?如果是這樣,請檢查/ var/log/mail *中的maillog ...此外,如果您在電子郵件之前丟失了@,您可能會收到一條有用的錯誤消息,以便與... – Carpetsmoker 2011-03-16 19:49:56
您安裝了哪個郵件服務器VPS? – mario 2011-03-16 19:51:12