Bluehost - Mailer Error- SMTP Error- Could not connect to SMTP host

Bluehost : Mailer Error: SMTP Error: Could not connect to SMTP host

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.

01<?php
02include("class.phpmailer.php");
03 
04function mail_new($fun_to,$fun_subject,$fun_body,$fun_header,$fun_from,$fun_cc){
05$mail = new PHPMailer();
06 
07$mail->IsSMTP();                                      // set mailer to use SMTP
08$mail->Host = "mail.eparinay.com"// specify main and backup server
09//$mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
10$mail->SMTPAuth = true;     // turn on SMTP authentication
11$mail->Username = "support@purabtech.in"// SMTP username
12$mail->Password = "YOURPSSSWORD"; // SMTP password
13$mail->Port       = 26;
14 
15$mail->From = $fun_from;
16$mail->FromName = "eparinay.com";
17$mail->AddAddress($fun_to);
18$mail->AddReplyTo($fun_from, $fun_from);
19 
20if($fun_cc!=""){
21$mail->AddAddress($fun_cc);
22}
23$mail->WordWrap = 50;                                 // set word wrap to 50 characters
24//$mail->AddAttachment("/var/tmp/file.tar.gz");         // add attachments
25//$mail->AddAttachment("/tmp/image.jpg", "new.jpg");    // optional name
26$mail->IsHTML(true);                                  // set email format to HTML
27 
28$mail->Subject = $fun_subject;
29$mail->Body    = $fun_body;
30//$mail->AltBody = "This is the body in plain text for non-HTML mail clients";
31 
32if(!$mail->Send())
33{
34echo "Message could not be sent. <p>";
35echo "Mailer Error: " . $mail->ErrorInfo;
36exit;
37}
38}
39?>

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.

Bluehost - Mailer Error- SMTP Error- Could not connect to SMTP host
Bluehost – Mailer Error- SMTP Error- Could not connect to SMTP host

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

2 thoughts on “Bluehost : Mailer Error: SMTP Error: Could not connect to SMTP host”

Leave a Reply to cory Cancel reply

Your email address will not be published.