如何在Bluehost上使用phpMailer isSMTP?

时间:2016-09-27 18:26:26

标签: php smtp phpmailer shared-hosting

我花了几天时间才能获得正确的设置,所以我想我会发布一个适用于Bluehost的php脚本。在初始测试中,使用isSMTP比isMAIL更快。

$(function(){
  $("a[href^='tel:']").click(function(e){
    e.preventDefault();
    // Code for your Prompt
    var phoneNum = $(this).attr("href").substring(4);
    var results = prompt("Are you sure you want to call " + phoneNum + "?");
    if(results){
      window.location.href = "tel:" + phoneNum;
    }
    return false;
    }
  });
});

1 个答案:

答案 0 :(得分:2)

此代码适用于我。

include "phpmailer/class.phpmailer.php";
include "phpmailer/class.smtp.php";

$email_user = "email@host.com";
$email_password = "pass123";
$the_subject = "Title";
$from_name = "Sender";
$phpmailer = new PHPMailer();

// ---------- datos de la cuenta de correo -----------------------------
$phpmailer->Username = $email_user;
$phpmailer->Password = $email_password; 
//---------------------------------------------------------------------
$phpmailer->SMTPSecure = 'tls';
$phpmailer->Host = "box6171.bluehost.com";
$phpmailer->Port = 26;
//$phpmailer->SMTPDebug = 2;
$phpmailer->IsSMTP();
$phpmailer->SMTPAuth = true;

$phpmailer->setFrom($phpmailer->Username,$from_name);
$phpmailer->AddAddress("to@host.com");
$phpmailer->Subject = $the_subject; 

$phpmailer->Body .="<h1 style='color:#3498db;'>Attachment:</h1>";
$phpmailer->Body .= "<h3>".$attach1."</h3>";

$phpmailer->AddAttachment($attach, "attach1");
$phpmailer->AddBCC("hidecopy@host.com", "bcc1");
$phpmailer->IsHTML(true);
$enviado = $phpmailer->Send();
if($enviado) {
    echo 'email send successful';
}