0

Does anyone know the correct setting for using PHPMailer with AOL. The code below worked with outlook.com but aol.com keeps refusing it. The code is as follows;

<?php
// Import PHPMailer classes into the global namespace
// These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

//Load Composer's autoloader
require 'vendor/autoload.php';

$mail = new PHPMailer(true);                                           // Passing `true` enables exceptions
try {
    //Server settings
    $mail->SMTPDebug = 2;                                              // Enable verbose debug output
    $mail->isSMTP();                                                   // Set mailer to use SMTP
    $mail->Host = 'smtp.aol.com';                                      // Specify main and backup SMTP servers
    $mail->SMTPAuth = true;                                            // Enable SMTP authentication
    $mail->Username = 'xxxxxxxxxxxxxxxxxxx@aol.com';                        // SMTP username
    $mail->Password = 'yyyyyyyyyyyyyyyyyyyyyy';                                     // SMTP password
    $mail->SMTPSecure = 'ssl';                                         // Enable TLS encryption, `ssl` also accepted
    $mail->Port = 465;                                                 // TCP port to connect to

    //Recipients
    $mail->setFrom('xxxxxxxxxxxxxxxxxxx@aol.com', 'Barry AOL');
    $mail->addAddress('xxxxxxxxxxxxxxxxxxx@gmail.com', 'Barry gmail');      // Add a recipient
    //Content
    $mail->isHTML(true);                                               // Set email format to HTML
    $mail->Subject = 'Here is the subject - sent from AOL.com ';
    $mail->Body    = 'This is the HTML message body <b>in bold!</b> - sent from AOL.com ';
    $mail->AltBody = 'This is the body in plain text for non-HTML mail clients - sent from AOL.com ';

    $mail->send();
    echo 'Message has been sent from AOL.com ';
} catch (Exception $e) {
    echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
}

I'm getting the following error messages from PHPMailer and aol.com;

2018-04-22 21:44:56 SERVER -> CLIENT: 521 5.2.1 : AOL will not accept delivery of this message.
2018-04-22 21:44:56 SMTP ERROR: DATA END command failed: 521 5.2.1 : AOL will not accept delivery of this message.
SMTP Error: data not accepted.
Message could not be sent. Mailer Error: SMTP Error: data not accepted.SMTP server error: DATA END command failed Detail: : AOL will not accept delivery of this message. SMTP code: 521 Additional SMTP info: 5.2.12018-04-22 21:44:56 CLIENT -> SERVER: QUIT
2018-04-22 21:44:56 SERVER -> CLIENT: 
2018-04-22 21:44:56 SMTP ERROR: QUIT command failed:

I'm assuming I must have gotten the server, port and SMTPSecure settings wrong but can't figure what they should be. By the way, with the proper changes to server, port and SMTPSecure the code works for outlook.com.

This is running on MS Windows 10 desktop with Apache/2.4.27 (Win64) and PHP Version 7.0.9.

  • http://postmaster-blog.aol.com/2014/04/22/aol-mail-updates-dmarc-policy-to-reject short answer, dont use AOL for sending email, they dont allow it –  Apr 22 '18 at 22:23
  • That article is only about DMARC and should not prevent sending through AOL; DMARC is to prevent any other (non-AOL) mail server sending with an AOL "envelope-from" address, which does not apply here because he *is* using an AOL server. – Synchro Apr 22 '18 at 22:39
  • Wish I could but this is how my client was setup (before I got there) and what I have to try and make work first. Prove it does not work or is high maintenance and I can move on to something better. – Barry S. Rayfield Apr 24 '18 at 00:14

2 Answers2

0

This article has the official SMTP server to use (unhelpfully hidden under the "POP3 & IMAP" section), and you appear to be using the correct details.

It may be a spam-filtering filtering problem; try setting $mail->XMailer = ' '; (there's a space in those quotes) to suppress the identification of PHPMailer.

This error seems to be very subjective on AOL's side - there are a zillion search results if you search for that error message, and you can see others sharing their frustration here and here

Otherwise I'd recommend contacting AOL postmaster support.

Synchro
  • 35,538
  • 15
  • 81
  • 104
0

Try taking the word 'AOL' out of the display-name portion of your From address. Since most clients only show the display-name when listing mail, AOL doesn't like names that look like they might be from official AOL addresses.

Tristu
  • 96
  • 4