Question

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: donotreply@domain.com : 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 = "donotreply@domain.com";

$mail->Password = "mypassword";

$mail->From = "donotreply@domain.com";

$mail->FromName = "Domain";

$mail->AddAddress("testaddress@gmail.com");

$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?

Was it helpful?

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.

OTHER TIPS

It took me a lot of digging to figure out the CentOS 7 disables SMTP connections by default.

Try running these lines if you run into this " Mailer Error: The following From address failed: " and "Called Mail() without being connected."

sudo setsebool -P httpd_can_sendmail 1 sudo setsebool -P httpd_can_network_connect 1

Thanks to the following web article:

https://gistpages.com/posts/phpmailer_smtp_error_failed_to_connect_to_server_permission_denied_13_fix

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top