phpemailmailtoaol

PHP Email is not sending to AOL


I have this script to send Email to a user on registration. The proble is that it sends to every email client except for AOL. This is is an issue as my client and her clients mainly use AOL Email. Is there something wrong with my code or is there a workaround? Thanks in advance.

$to = $EMSPosted_s; $subject = "Confirmation of Order";

 $message = "
 <html>
 <head>
 <title>Confirmation of Order</title>
    </head>
      <body>
 <h1>Welcome to your Here To Thrive Course!</h1>
 <h2>Hi ".$UNSPosted_s."</h2>
  <h3>Thank you for purchasing the Here To Thrive course from x</h3>

 <h5>Many thanks</h5>

 <h4>Louise</h4>

  <p>www.louiselloyd.life</p>
 </body>
  </html>";

 $headers = "MIME-Version: 1.0" . "\r\n";
 $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";


$headers .= 'From: <confirmation@louiselloyd.life>' . "\r\n";
$headers .= 'Cc: louise@louiselloyd.life' . "\r\n";

  mail($to,$subject,$message,$headers);

  ?>

Solution

  • PHP's default mail() function doesn't work most of the times, especially with GMail or with AOL as in your case. This is because your e-mail needs to be formatted in a special way to be accepted by certain mail servers. You'll be better off using a mail library like PHPMailer.

    Here's how to send an e-mail using PHPMailer from a GMail Account.

        $mail = new PHPMailer();
    
        // ---------- adjust these lines ---------------------------------------
        $mail->Username = "xxx@gmail.com"; // your GMail user name
        $mail->Password = "passwd";  // your GMail Password
        $mail->AddAddress("yyy@gmail.com"); // recipients email
        $mail->FromName = "Your Name"; // readable name
    
        $mail->Subject = "Subject";
        $mail->Body    = "Body"; 
    
        $mail->Host = "smtp.gmail.com";
        $mail->Port = 465; // or 587
        $mail->IsSMTP(); // use SMTP
        $mail->SMTPAuth = true; // turn on SMTP authentication
        $mail->From = $mail->Username;
    
        //----------------------------------------------------------------------
    
        if(!$mail->Send())
        {
            echo "mail sent";
        }