php SMTP 发送 邮件

var_dump(wp_mail( '****@qq.com', 'The subject', 'The message' )); 

echo !extension_loaded('openssl')?"Not Available":"Available";

require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = "smtp.gmail.com"; 
$mail->SMTPDebug  = 2;
$mail->SMTPAuth   = true;           
$mail->SMTPSecure = "ssl";
$mail->Port = 465;  
$mail->Username = '****@gmail.com';
$mail->Password = '*****';
$mail->addAddress('***@gmail.com', 'Josh hsl');
$mail->Subject = 'PHPMailer GMail SMTP test';
$body    = 'This is the HTML message body <b>in bold!</b>';
$mail->MsgHTML($body);
if (!$mail->send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message sent!";
}

你可能感兴趣的:(php SMTP 发送 邮件)