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梅勒的依赖,而且它正在发送的实际的邮件。我更喜欢一种只显示发送邮件时的样子。 –