还有许多其他库.他们之中有一些是 :
您可以使用任何这些库使用SMTP从PHP发送邮件
使用带有PHPMailer库的Gmail帐户发送邮件的示例如下:
//include the file
require_once('class.phpmailer.php');
$phpmailer = new PHPMailer();
$phpmailer->IsSMTP(); // telling the class to use SMTP
$phpmailer->Host = "ssl://smtp.gmail.com"; // SMTP server
$phpmailer->SMTPAuth = true; // enable SMTP authentication
$phpmailer->Port = 465; // set the SMTP port for the GMAIL server; 465 for ssl and 587 for tls
$phpmailer->Username = "yourname@yourdomain"; // Gmail account username
$phpmailer->Password = "yourpassword"; // Gmail account password
$phpmailer->SetFrom('name@yourdomain.com', 'First Last'); //set from name
$phpmailer->Subject = "Subject";
$phpmailer->MsgHTML($body);
$phpmailer->AddAddress($to, "To Name");
if(!$phpmailer->Send()) {
echo "Mailer Error: " . $phpmailer->ErrorInfo;
} else {
echo "Message sent!";
}
Run Code Online (Sandbox Code Playgroud)
希望这对你有所帮助