Tyluur
Tyluur

Reputation: 91

Error sending email PHP

I found some php code online and made some alterations to it so that it would work for me. The goal of this is to send an email to the recipient with the message I want, from my email at my domain. It has worked for me for some emails, but when I send the email to the list of emails I have, I get an error back in my inbox with the following text

Title - "Undelivered Mail Returned to Sender"

Message - "
This is the mail system at host gateway06.websitewelcome.com.

I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.

For further assistance, please send mail to postmaster.

If you do so, please include this problem report. You can
delete your own text from the attached returned message.

                   The mail system

<[email protected]>: host mailin-04.mx.aol.com[64.12.88.131] said: 550
    5.1.1 <[email protected]>: Recipient address rejected: aol.com (in
    reply to RCPT TO command)"

The code that I am using to send the email to the recipient is as shown below:

<?php
include("Mail.php"); 

$recipients = $_GET['email'];

$headers["From"]    = ""; 
$headers["To"]      = $recipients; 
$headers["Subject"] = ""; 

$body = ''; 

$params["host"] = ""; 
$params["port"] = "25"; 
$params["auth"] = true; 
$params["username"] = ""; 
$params["password"] = ""; 

// Create the mail object using the Mail::factory method 
$mail_object =& Mail::factory("smtp", $params); 

$mail_object->send($recipients, $headers, $body); 

?>

What am I doing wrong? Why is it working for some recipients (I tried with two people using @gmail.com emails), and not working for others?

Upvotes: 0

Views: 971

Answers (2)

Giacomo1968
Giacomo1968

Reputation: 26066

The script is fine & clearly sent the message. The mail was simply bounced which is not a factor of the script but of the mail transport process failing. That said, this seems like either:

  1. An e-mail address that is simply incorrect or dead.
  2. Mails from your server are being rejected by AOL.com because it doesn’t meet their criteria for real (aka: non-spam) e-mail. Either a PTR record needs to be set or SPF records need to be adjusted.

Will expand on point number 2 based on my own personal experiences: AOL.com is pretty well known as a recipient who will bounce messages if they fail certain standards. The most common one I run into is the lack of a PTR (aka: reverse DNS record) on a part of the sending machine. Or perhaps the SPF (Sender Policy Framework) record for your domain not validating your IP address.

PTR & SPF are topics onto themselves, but I have a gut feeling that one or both of those have to be fixed on your side—as the sender—to get e-mails to send properly to AOL.com.

Upvotes: 2

zeflex
zeflex

Reputation: 1527

Your email has been bounced. Your mail system works correctly but your 'TO' destination didn't accept your email for X reasons.

http://en.wikipedia.org/wiki/Bounce_message

Upvotes: 0

Related Questions