Reputation: 425
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?
Upvotes: 0
Views: 9241
Reputation: 171
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:
Upvotes: 0
Reputation: 425
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.
Upvotes: 3