0
我正在開發電子郵件排隊應用程序PHP我想測試郵件是否正確發送或不正確。據我所知,我知道以下方法如何測試來自ubuntu本地主機的電子郵件
- sendmail。
- Postfix。
但是這些方法需要SMTP。有沒有其他方法可以實現這一點?
我正在開發電子郵件排隊應用程序PHP我想測試郵件是否正確發送或不正確。據我所知,我知道以下方法如何測試來自ubuntu本地主機的電子郵件
但是這些方法需要SMTP。有沒有其他方法可以實現這一點?
您可以使用phpmailer類。 PHPMailer的是一個不錯的選擇
<?php
$mail = new PHPMailer(true);
//Send mail using gmail
if($send_using_gmail){
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = "[email protected]"; // GMAIL username
$mail->Password = "your-gmail-password"; // GMAIL password
}
//Typical mail data
$mail->AddAddress($email, $name);
$mail->SetFrom($email_from, $name_from);
$mail->Subject = "My Subject";
$mail->Body = "Mail contents";
try{
$mail->Send();
echo "Success!";
} catch(Exception $e){
//Something went bad
echo "Fail - " . $mail->ErrorInfo;
}
?>
謝謝馬尼什的答案,但這個有PHP梅勒的依賴,而且它正在發送的實際的郵件。我更喜歡一種只顯示發送郵件時的樣子。 –