Click here to Skip to main content
15,888,044 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using PHPMailer to send email, but I always get the error above.

include("PHPMAILER/class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth   = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port  = 465;
$mail->Mailer= "smtp";
$mail->Username   = "tx@gmail.com";
$mail->Password   >= "password";
$mail->AddReplyTo ("txtmachado03@gmail.com", "Recipient Name");
$mail->From = "txtmachado03@gmail.com";
$mail->FromName = "Sender Name";
$mail->Subject = "Email Subject";
$mail->Body = "Email Content…";
$mail->WordWrap = 50;
$mail->AddAddress ("txtmachado03@gmail.com", "Receiver Name");
$mail->IsHTML (true);
$mail->Send ();


Many tutorials I read it says that we have to enable the php extension (openssl), but I don't find it on ubuntu. I also do not know if it's installed by default because when I do this:

apt-cache search php|egrep ^php5-

does not appear any extension related to ssl (however openssl package is installed)

Can you please help me ?
Posted
Updated 2-Mar-17 19:55pm

Write a simple page with
PHP
<?php phpinfo(); ??>

That will tell you all sorts of stuff about your server and what extensions are included. Then you should be able to work out why you can't authenticate. If you try changing username, password, etc, you should be able to figure out how far your auth attempt are getting.

Cheers,
Peter
 
Share this answer
 
Comments
Maxdd 7 21-Jun-11 21:48pm    
I have openssl enabled. So what now ?
Peter_in_2780 21-Jun-11 22:17pm    
Have you tried the PHPmailer project at http://phpmailer.sourceforge.net/ ? They are probably your best source. Also, you might take a look at Drupal, which uses PHPmailer. They have some instructions on installation and setup (in their context, of course).
Maxdd 7 22-Jun-11 8:49am    
I'm using PHP Mailer with that code ;) Also, the code works with another configuration (another smtp server), only for Gmail does not seem to work.
Peter_in_2780 22-Jun-11 17:25pm    
I haven't looked at it in detail, but Drupal has a discussion specifically about getting PHPMailer to work with gmail.
Goto Account of Gmail , then select Connected apps & sites Allow less secure apps: ON(if this is off you cannot send mails through apps,or your websites )
 
Share this answer
 
Comments
Graeme_Grant 3-Mar-17 2:06am    
Please stop answering very old questions. This can get you banned.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900