1

I have tried to use PHPMailer to send an email from localhost (XAMPP Installation).

my code:

<?php
require 'PHPMailer/PHPMailerAutoload.php';

$mail             = new PHPMailer();

$body             = "Message Body";

$mail->Mailer = "smtp"; 
$mail->Host = "ssl://smtp.gmail.com"; 
$mail->Port = 465; 
$mail->SMTPAuth = true; // turn on SMTP authentication 
$mail->Username = "myemailaddress@gmail.com"; // SMTP username 
$mail->Password = "secret"; // SMTP password 
//$mail->IsSMTP(); // telling the class to use SMTP
$mail->SetFrom('from@address.com', 'First Last');

$mail->Subject    = "PHPMailer Test Subject via smtp, basic with authentication";

$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML($body);

$mail->AddAddress('myemailaddress@gmail', 'First Last');

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

Please note that whenever I use myemailaddress@gmail.com in the above, it is replaced for my real email address, same goes for password secret.

I get following error

Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

going to above mentioned website did not help. I tried following:

SMTP Connect() failed. Message was not sent.Mailer error: SMTP Connect() failed

Community
  • 1
  • 1
pokrak94
  • 198
  • 1
  • 4
  • 20
  • Check your firewall. – SLaks Nov 19 '16 at 23:36
  • did that, had it turned off for the time being - same story. – pokrak94 Nov 19 '16 at 23:37
  • Possible duplicate of [SMTP Connect() failed. Message was not sent.Mailer error: SMTP Connect() failed](http://stackoverflow.com/questions/18496650/smtp-connect-failed-message-was-not-sent-mailer-error-smtp-connect-failed) – GreenReaper Nov 20 '16 at 02:35
  • but I said I went to this link and it did not help, can you please read everything properly before scamming me for duplicate questions? – pokrak94 Nov 20 '16 at 18:45

0 Answers0