Jump to content

SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not


NaniG

Recommended Posts

Firstly I'd like to say a hello to everyone.

 

OK, I'm having a problem with my PHPMailer setup. My aim is to have a registration email sent to a user upon sign up from (admin@mydomain.com). I have set up my mail servers set up correctly. so I can send/recieve mail from (admin@mydomain.com).

 

I am using PHPMailer_v5.1, and am using the following code

 

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

require_once('../class.phpmailer.php');

$mail = new PHPMailer();

$body = file_get_contents('contents.html');
$body = eregi_replace("[\]",'',$body);

$mail->IsSMTP();
$mail->Host = "admin@mydomain.com";
$mail->SMTPDebug = 1;

$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "admin@mydomain.com";
$mail->Port = 25;
$mail->Username = "admin@mydomain.com";
$mail->Password = "*****"; 

$mail->SetFrom('admin@mydomain.com","My Domain');
$mail->AddReplyTo("admin@mydomain.com","My Domain");
$mail->Subject = "PHPMailer Test Subject via smtp, basic with authentication";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
$mail->MsgHTML($body);

$address = "test@test.com";
$mail->AddAddress($address, "Test");

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

 

I set up a PHP document to test this mail feature, but every time I load it, it displays this

 

SMTP -> ERROR: Failed to connect to server: (0)

SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host.

 

The PHPMailer is running on Elastiks (CentOS Linux 5.6).

 

I cross checked the php.ini file and  the OpenSSL is enabled.

 

openssl

OpenSSL support  enabled 

OpenSSL Version  OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008 

 

Please help me out from these issue.

 

Thanks for your time guys, hope someone can get back to me soon!

Link to comment
Share on other sites

hello :)

 

i would test a simple send with mail() before debugging that:

 

http://php.net/manual/en/function.mail.php

bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )

<?php
mail('caffeinated@example.com', 'My Subject', $message);
?>

 

that will confirm that php smtp is working, and then you can debug phpmailer

Link to comment
Share on other sites

Thanking you guys for quick reply!

 

Already i used the mail() function in my pages. but the problem is that the mail is going into spam. To avoid this, i wanted to use the PHPMailer with SMTP authentication. We have created our own domain and we wants to go all the mails through our domain.

 

$mail->host='mail.domainname.com';

 

Again am getting the same error :

 

SMTP -> ERROR: Failed to connect to server: (0)

SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host.

 

Please help me out from these issue.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.