Search code examples
phpsmtpphpmailerzoho

Phpmailer from address failed


I currently have my site hosted on freehostia, which doesn't allow SMTP. As a work around for this I created an account at Zoho (www.zoho.com) which lets you link your domain to their server and send and receive email through them. I have also installed phpmailer on my host as instructed.

I have created a test file using the smtp information given by Zoho, and as far as I can tell everything is set up correctly.
The problem is that when I try to send mail I get the error: Mailer Error: The following From address failed: [email protected] : Called Mail() without being connected

The code I have for my test file looks like this:

<?php
require '../PHPMailer-master/class.phpmailer.php';

$mail = new PHPMailer();

$mail->IsSMTP();

$mail->SMTPAuth = true;

$mail->SMTPSecure = "ssl";

$mail->Host = "smtp.zoho.com";

$mail->Port = 465;

$mail->Username = "[email protected]";

$mail->Password = "mypassword";

$mail->From = "[email protected]";

$mail->FromName = "Domain";

$mail->AddAddress("[email protected]");

$mail->Subject = "Test with PHPMailer";

$mail->Body = "This is a sample body text!";

$mail->IsHTML (true);

if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo "Message sent!";
}

?>

Any advice?


Solution

  • It turns out that the free plan through freehostia doesn't allow any outgoing connections, so trying to contact any outside mail server would have been impossible. Thanks for the suggestions though.