I am using the bluehost for my some sites hosting. For sending emails I used the SMTP service which is provided by bluehost.
Bluehost : Mailer Error: SMTP Error: Could not connect to SMTP host
I used the PHPmailer in my website for sending email. When I tried to use the bluehost SMTP I always got the following error message.
Mailer Error: SMTP Error: Could not connect to SMTP host.”
I solved this issue. I created the following function.
<?php include("class.phpmailer.php"); function mail_new($fun_to,$fun_subject,$fun_body,$fun_header,$fun_from,$fun_cc){ $mail = new PHPMailer(); $mail->IsSMTP(); // set mailer to use SMTP $mail->Host = "mail.eparinay.com"; // specify main and backup server //$mail->SMTPSecure = "ssl"; // sets the prefix to the servier $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = "support@purabtech.in"; // SMTP username $mail->Password = "YOURPSSSWORD"; // SMTP password $mail->Port = 26; $mail->From = $fun_from; $mail->FromName = "eparinay.com"; $mail->AddAddress($fun_to); $mail->AddReplyTo($fun_from, $fun_from); if($fun_cc!=""){ $mail->AddAddress($fun_cc); } $mail->WordWrap = 50; // set word wrap to 50 characters //$mail->AddAttachment("/var/tmp/file.tar.gz"); // add attachments //$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name $mail->IsHTML(true); // set email format to HTML $mail->Subject = $fun_subject; $mail->Body = $fun_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; exit; } } ?>
Where you want to use the mail you just need to include the above script and call the “mail_new” function for sending email through bluehost.