2
我需要花费几天时间才能获得正确的设置,所以我想我会发布一个适用于Bluehost的php脚本。在初始测试中使用isSMTP比isMAIL更快。如何在Bluehost上使用phpMailer isSMTP?
<?php
require_once '../includes/phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "box1311.bluehost.com"; // specify bluehost as outgoing server
$mail->SMTPSecure = "tls"; // sets the prefix to the server do not use ssl
$mail->SMTPDebug = 3; // comment out if you don't need debug info
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "[email protected]"; // SMTP username (your email account)
$mail->Password = "PASSWORD"; // SMTP password
$mail->Port = 25;
$mail->From = '[email protected]';
$mail->FromName = "[email protected]";
$mail->AddAddress('[email protected]');
$mail->IsHTML(true); // set email format to HTML
$mail->Subject = 'test message';
$body = '<!DOCTYPE html>
<html><header>
</header>
<body lang=EN-US>
<div style="text-align:center">
<h2>this is a test</h2>
</div>
</body>
</html>';
$mail->Body = $body;
$mail->AltBody = "This is the body in plain text for non-HTML mail clients";
if(!$mail->Send()){
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
}else{
echo '<h1>message sent</h1>';
}
?>
如果这是一个解决方案,你应该发布一个(可搜索的)问题,然后张贴你的贡献作为一个实际的答案。 [你可以回答你自己的问题](http://meta.stackexchange.com/q/17463/300177),并会看到一个复选框,说***你想回答你自己的问题吗?***(或者这个效果的东西)。 –
非常感谢你!帮助了我很多! –