I get this error when trying to send e-mail form with PHP Mailer 5.1:

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

<?php
require("PHPMailer5\class.phpmailer.php");

$mail = new PHPMailer();

$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'tls';
$mail->SMTPSecure = 'ssl';
$mail->Host = 'smtp.live.com';
$mail->Port = 25; 
$mail->Username = 'davy_yg@hotmail.com';
$mail->Password = '****'; 

$mail->From='davy_yg@hotmail.com';
$mail->FromName="My site's mailer";
$mail->Body = $newcomments;
$mail->Sender='davy_yg@hotmail.com';
$mail->AddReplyTo("replies@example.com", "Replies for my site");
$mail->AddAddress("plasteezy@yahoo.com");
//$mail->Subject = $subject;
$mail->IsHTML(true);#$mail->AddAttachment('http://www.branddesignexpress.com/images/homepage_mainimage.jpg', 'homepage_mainimage.jpg');
$mail->AddEmbeddedImage('homepage_mainimage.jpg', 'logoimg', 'homepage_mainimage.jpg'); // attach file logo.jpg, and later link to it using identfier //logoimg$mail->Body = $msg;$mail->AltBody="This is text only alternative body.";
if(!$mail->Send()){   echo "Error sending: " . $mail->ErrorInfo;

}else{   echo "Letter is sent";}
?>

What did I do wrong in the setting? or perhaps I should find a new php mailer. What version would be better? What's the link (I've looking for another link but do not find another link for PHP Mailer version 5 and above.

A quick search showed that you should use tls and port 587, however I've never tried these settings myself.

The latest version of PHPMailer is 5.2.0

I've update my php mailer to version 5.2.0 and set it to my yahoo account since I still receive the SMTP error to my hotmail account.

<?php
require("PHPMailer5\class.phpmailer.php");

$mail = new PHPMailer();

$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'SSL';
$mail->Host = 'smtp.mail.yahoo.com';
$mail->Port = 25; 
$mail->Username = 'davy_yg@yahoo.com';
$mail->Password = '****'; 

$mail->From='davy_yg@yahoo.com';
$mail->FromName="My site's mailer";
$mail->Body = $newcomments;
$mail->Sender='davy_yg@yahoo.com';
$mail->AddReplyTo("replies@example.com", "Replies for my site");
$mail->AddAddress("plasteezy@yahoo.com");
//$mail->Subject = $subject;
$mail->IsHTML(true);#$mail->AddAttachment('http://www.branddesignexpress.com/images/homepage_mainimage.jpg', 'homepage_mainimage.jpg');
$mail->AddEmbeddedImage('homepage_mainimage.jpg', 'logoimg', 'homepage_mainimage.jpg'); // attach file logo.jpg, and later link to it using identfier //logoimg$mail->Body = $msg;$mail->AltBody="This is text only alternative body.";
if(!$mail->Send()){   echo "Error sending: " . $mail->ErrorInfo;

}else{   echo "Letter is sent";}
?>

Letter is sent. yet, I do not see the e-mail even after refresh my inbox. It's not in junk mail either. I also try it send it to my other yahoo mail account the same way occured. If it's not working in my yahoo e-mail and it's not the php mail problem either (since I already try to use another new version) then must find the correct setting for hotmail account.

Warning: fputs() expects parameter 1 to be resource, integer given in C:\xampp\htdocs\Masterlink\cgoods\PHPMailer5\class.smtp.php on line 215
SMTP Error: Could not authenticate. Error sending: SMTP Error: Could not authenticate.

I keep receiving those error message after changing the port to: 465

http://techblissonline.com/yahoo-pop3-and-smtp-settings/

If it's incorrect I wonder why using port 25 works! (Letter sent! message) eventhough I do not receive the actual message.

------------------

Port 25 should work too for SMTP:
http://answers.yahoo.com/question/index?qid=20090826172858AA1b3zi

I just wondering though why the actual e-mail is not being sent to my e-mail. Others e-mail I can receive but from "My site's mailer" not.

Is there any other alternative to use in contact form besides php mailer. I have not successfully receive e-mail by php mailer?

for my hotmail account it always SMTP connection prob, while for my yahoo mail it appears success but I cannot find the e-mail in my inbox.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.