Charles
Charles

Reputation: 189

PHPMailer send address failed

I have this PHP code using the PHPMailer library

 $email = new PHPMailer();

$email->IsSMTP();
$email->SMTPAuth   = $Email_SMTPAuth;
$email->Host       = $Email_Host;
$email->Port       = $Email_Port;
$email->Username   = $Email_Username;
$email->Password   = $Email_Password;

$email->setFrom($result["emailfrom"], $result["fromname"]);

$email->Subject   = stripslashes($result["subject"]);
$email->Body      = stripslashes($result["message"]);

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

if(!$email->Send()) {
    echo $email->ErrorInfo;
} else {
    echo 'sent';
}

When it fails to send, it show the error message:

The following From address failed: *EMAIL_ADDRESS_HERE* : Called Mail() without being connected

Upvotes: 1

Views: 131

Answers (2)

Spyryto
Spyryto

Reputation: 1227

It happens frequently to me... when I forget to ask the provider to open a port to the host.

I have several sites hosted by a provider, and a DEM application running on the server. Depending on the provider, the server can be secured so that you are not allowed to connect freely to any SMTP host/port, but you have to be enabled to.

Upvotes: 1

Erick Martim
Erick Martim

Reputation: 112

I believe it can be something to do with your host and port configuration, PHP Mailer might not be able to connect to your server with the settings you provided, thus giving you this error. Try checking again the configuration you set up, the host, port and username with your host and see if everything's all right.

Here is something similar to the error you're getting. Hope it helps :)

Upvotes: 2

Related Questions