0

I have problem with PHP Mailer, Im sure that my data is correct beacuse i used it to test on SMTP Test site, and he sends mail correct, but from Mailer it dont work.

require './libs/PHPMailer-master/class.phpmailer.php';

$mail = new PHPMailer;

$mail->SMTPDebug = SMTP::DEBUG_SERVER;
$mail->IsSMTP();                                      // Set mailer to use SMTP
$mail->Port = 25;
$mail->Host = 'my.server.com';                  // Specify main and backup server
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = 'my@mail.com';                                // SMTP username
$mail->Password = 'mypass';                           // SMTP password
$mail->SMTPSecure = 'tls';                            // Enable encryption, 'ssl' also accepted

$mail->From = 'my@mail.com';
$mail->FromName = 'Name';

echo "Mail sended";

$mail->WordWrap = 50;                                 // Set word wrap to 50 characters
$mail->IsHTML(true);                                  // Set email format to HTML

?>```

Thank you on help in advance.
HHDev
  • 13
  • 6

1 Answers1

0

Before you do anything else, you're using an old version of PHPMailer, so upgrade.

The reason your script is not sending email is because... you're not telling it to.

You have missed out a call to $mail->send();.

I can also see you have based your code on an old example, so you might find it easier to start again using the example code provided in the readme.

Synchro
  • 35,538
  • 15
  • 81
  • 104
  • Hello, I added it, and still mail not delivered – HHDev Jul 02 '19 at 14:27
  • I added $mail->send(); under $mail->FromName = ''; but again It's not delivered – HHDev Jul 02 '19 at 14:40
  • It should be the *last* thing you do, not somewhere in the middle. You've also omitted to set `Body` (so there's nothing to send), and you have no error checking to see where the problem might be. Please do as I suggested and start again with the readme example which makes none of these mistakes; it will be much quicker than fixing the code you have here. – Synchro Jul 02 '19 at 18:49
  • I fixed it, thank you, it was server delayement. – HHDev Jul 03 '19 at 00:30