-2
我想用PHP郵件()函數診斷電子郵件問題。該表格託管在1臺和1臺專用服務器上,其中site1.com(腳本託管的站點和站點2(我們的站點))。site1.com使用交換服務器管理它的電子郵件和我們的站點(site2.com )使用谷歌應用程序PHP郵件不會發送到交換或谷歌應用程序帳戶
郵件表格不會發送到site1.com或site2.com,但它會發送到我的個人gmail帳戶沒有afflations到site1.com或site2.com。有沒有人有任何想法?
這裏是郵件代碼:
if(isset($_POST["submit_contact"]))
{
// Set submitted variable
$submitted = TRUE;
// Get data and add to variables
$m_name = mysql_real_escape_string($_POST["name"]);
$m_email = mysql_real_escape_string($_POST["email"]);
$m_company = mysql_real_escape_string($_POST["company"]);
$m_phone = mysql_real_escape_string($_POST["phone"]);
$m_enquiry = mysql_real_escape_string($_POST["enquiry"]);
$dateadded = gmdate("Y-m-d H:i:s");
$ip = $_SERVER['REMOTE_ADDR'];
$type = "Website Submission";
/// Set error messages ///
$emailError = "Sorry this e-mail is not valid, please try again.";
///////////SECURITY CHECKS///////////////////
/// Check E-mail Authenticity ///
if(!preg_match('#^[a-z0-9.!\#$%&\'*+-/=?^_`{|}~][email protected]([0-9.]+|([^\s]+\.+[a-z]{2,6}))$#si', $m_email)) {
$message = $emailError;
$error = TRUE;
}
// Set email message //
$errorMessage = "Sorry, you cannot add URLS in this contact form";
/// Check for urls ///
if(preg_match("/http/i", "$m_name")) { $message = $errorMessage; $error = TRUE; }
if(preg_match("/http/i", "$m_email")) { $message = $errorMessage; $error = TRUE; }
if(preg_match("/http/i", "$m_company")) { $message = $errorMessage; $error = TRUE; }
if(preg_match("/http/i", "$m_phone")) { $message = $errorMessage; $error = TRUE; }
if(preg_match("/http/i", "$m_enquiry")) { $message = $errorMessage; $error = TRUE; }
//// END SECURITY CHECKS ////
if(!$error) {
/// Send E-Mail ///
$em_to = "[email protected],[email protected],[email protected]";
$em_subject = "Website Contact Form Submission";
$em_message = "
<strong>Name:</strong> $m_name<br />
<strong>Email:</strong> $m_email<br />
<strong>Phone:</strong> $m_phone<br />";
if(isset($_POST["callSub"]))
{
$em_message .= "<strong>Time to call:</strong> $m_enquiry<br />";
} else {
$em_message .= "<strong>Company:</strong> $m_company<br />
<strong>Message:</strong> $m_enquiry<br />";
}
$em_message .= "<br /><br />
<strong>Date Submitted:</strong> $dateadded<br />
<strong>IP Address:</strong> $ip<br />";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: "site1" <'.$m_email.'>\r\n';
if(mail($em_to, $em_subject, $em_message, $headers)) {
$error = FALSE;
$message = "<h3>Thank you for your enquiry, we'll be in touch soon!</h3>";
} else {
$error = TRUE;
$message = "Sorry there was an error processing the form. Please go back and try again.";
}
該腳本起作用。如果這些帳戶沒有收到這些電子郵件,那麼中間的東西就是您的問題。你需要弄清楚是什麼並解決這些問題。 – 2014-08-29 13:55:33
我該怎麼做呢? – 2014-08-29 13:58:23
看看maillog是否給你提供任何東西 – 2014-08-29 13:59:43