我一直在尋找答案,並嘗試了很多事情來解決這個問題。設置SMTP郵件()函數的SMTP詳細信息
我的腳本在我的虛擬主機上運行良好,但是當將其移動到其他專用服務器時,郵件從未獲得交付。現在,我需要設置SMTP服務器,但不正確。
使用Gmail應用程序btw。這是代碼的樣子。
<?php
if(!$_POST) exit;
$email = $_POST['email'];
//$error[] = preg_match('/\b[A-Z0-9._%-][email protected][A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS';
if(!eregi("@",$email)){
$error.="Invalid email address entered";
$errors=1;
}
if($errors==1) echo $error;
else{
$values = array ('name','email','telephone','message');
$required = array('name','email','telephone','message');
$your_email = "[email protected]";
$email_subject = "New Messag: ".$_POST['subject'];
$email_content = "New message:\n";
foreach($values as $key => $value){
if(in_array($value,$required)){
if ($key != 'subject' && $key != 'telephone') {
if(empty($_POST[$value])) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; }
}
$email_content .= $value.': '.$_POST[$value]."\n";
}
}
if(@mail($your_email,$email_subject,$email_content)) {
echo 'Message sent!';
} else {
echo 'ERROR!';
}
}
$mail->Mailer = "smtp";
$mail->Host = "ssl://smtp.gmail.com";
$mail->Port = 465;
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "[email protected]"; // SMTP username
$mail->Password = "password"; // SMTP password
?>
那麼我該如何設置SMTP設置?
檢查出這是一個完美的工作靈魂http://stackoverflow.com/questions/712392/send-email-using-gmail-smtp-server-from-php-page – 2011-05-23 07:23:25
)複製posible – Harsh 2011-05-23 07:51:35