I am trying to use php-mailer-class but getting different issue.
Please take a look on my code.
include ("class.phpmailer.php");
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug =1; // debugging: 1 = errors and messages, 2 = messages only
//$mail->SMTPAuth = true; // authentication enabled
$mail->Host = 'relay-hosting.secureserver.net';
$mail->Port = 25;
$mail->Username = "admin@****.in";
$mail->Password = "******";
$mail->SetFrom('*****0014@gmail.com', 'User name');
$mail->Subject = 'mailing';
$mail->Body = "<b>Hi, your e- mail has been received.</b>";
$mail->AddAddress("*****0014@gmail.com");
if(!$mail->Send()) {
$error = 'Mail error: '.$mail->ErrorInfo;
return false;
} else {
$error = 'Message sent!';
return true;
}
errors-:
SMTP -> ERROR: EHLO not accepted from server:
SMTP -> ERROR: HELO not accepted from server:
SMTP -> NOTICE: EOF caught while checking if connectedThe following From address failed: *****0014@gmail.com
This code is working well if I am using Gamil settings Not working with godaddy SMTP settings.
I checked your code, and expecting few reasons for the error.
- Port no/host declaration wrong
- SMTP class not available.
if the above both are solved, please modify the code by adding the extra line as follows.
$mail->Host = 'relay-hosting.secureserver.net';
$mail->Port = 25;
$mail->SMTPAuth = true;
This found working well in my server.
From THIS question, it describes the server blocking of SSL SMTP connection in shared hosting. So make the mailer to use TLS, to do so, change port no and SMTP mode.
$mail->SMTPSecure = "tls";
$mail->Port = 587;
And specifically you told that you are using godaddy hosting, as per This question, change your host configuration to
$mail->Host = localhost;
First include include("PHPMailerAutoload.php");
and PHPmailerAutoload.php will load a class that you need, in your case class.smtp.php.
include("PHPMailerAutoload.php");
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug =1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "box###.bluehost.com"; // sets the SMTP server
$mail->Port = 465; // set the SMTP port
$mail->Username = "admin@****.in";
$mail->Password = "******";
$mail->SetFrom('admin@****.in', 'Sender name');
$mail->Subject = 'mailing';
$mail->Body = "<b>Hi, your e- mail has been received.</b>";
$mail->AddAddress("*****0014@gmail.com", "User name");
if(!$mail->Send()) {
$error = 'Mail error: '.$mail->ErrorInfo;
return false;
} else {
$error = 'Message sent!';
return true;
}
@vipulsharma,Its simple, you don't need to mentions host url directly to "relay-hosting.secureserver.net" because you are using the shared hosting so you have to point your host destination to your localhost folder only. For shared hosting, GoDaddy already configured the host setting internally. do change in the following changes in your code.
$mail->Host= 'localhost';
$mail->ssl=false;
$mail->authentication=false;
$mail->Port=25;