PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
include('Mail.php');
include('Mail/mime.php');
// Constructing the email
$sender = "new <new@mail.com>";
$recipient = "George <geop@mail.com>";
$subject = "Test Email";
$text = 'This is a text message.';
$html = '<html><body><p>This is a html message!</p></body></html>';
$crlf = "\n";
$headers = array(
'From' => $sender,
'To' => $recipient,
'Return-Path' => $sender,
'Subject' => $subject
);
// Creating the Mime message
$mime = new Mail_mime($crlf);
// Setting the body of the email
$mime->setTXTBody($text);
$mime->setHTMLBody($html);
// Set body and headers ready for base mail class
$body = $mime->get();
$headers = $mime->headers($headers);
// SMTP params
$smtp_params["host"] = "localhost"; // SMTP host
$smtp_params["port"] = "25"; // SMTP Port (usually 25)
// Sending the email using smtp
$mail =& Mail::factory("smtp", $smtp_params);
$result = $mail->send($recipient, $headers, $body);
if($result == 1)
{
echo("Your message has been sent!");
}
else
{
echo("Your message was not sent: " . $result);
}
Is there any idea?
Help!!
Last edited by zenon on Mon May 11, 2009 7:39 pm, edited 1 time in total.
include('Mail.php');
include('Mail/mime.php');
// Constructing the email
$sender = "new <new@mail.com>";
$recipient = "George <geop@mail.com>";
$subject = "Test Email";
$text = 'This is a text message.';
$html = '<html><body><p>This is a html message!</p></body></html>';
$crlf = "\n";
$headers = array(
'From' => $sender,
'To' => $recipient,
'Return-Path' => $sender,
'Subject' => $subject
);
// Creating the Mime message
$mime = new Mail_mime($crlf);
// Setting the body of the email
$mime->setTXTBody($text);
$mime->setHTMLBody($html);
// Set body and headers ready for base mail class
$body = $mime->get();
$headers = $mime->headers($headers);
// SMTP params
$smtp_params["host"] = "localhost"; // SMTP host
$smtp_params["port"] = "25"; // SMTP Port (usually 25)
// Sending the email using smtp
$mail =& Mail::factory("smtp", $smtp_params);
$result = $mail->send($recipient, $headers, $body);
if($result == 1)
{
echo("Your message has been sent!");
}
else
{
echo("Your message was not sent: " . $result);
}
Is there any idea?
Help!!
Are you using XAMPP for your localhost in sending mail? Or is there any other platforms you are using.
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
<xxxxxxxx@hotmail.com>: host mx3.hotmail.com[65.54.244.72] said: 550
DY-001 Mail rejected by Windows Live Hotmail for policy reasons. We
generally do not accept email from dynamic IP's as they are not typically
used to deliver unauthenticated SMTP e-mail to an Internet mail server.
http://www.spamhaus.org maintains lists of dynamic and residential IP
addresses. If you are not an email/network admin please contact your
E-mail/Internet Service Provider for help. Email/network admins, please
visit http://postmaster.live.com for email delivery information and support
(in reply to MAIL FROM command)
I tried to deliver authenticated SMTP e-mail via postfix, but i got again the same answer.
Instead of localhost try testing it on a live site, hosted in a reputable server to see if those email can be sent. It is highly possible they block email addresses originating from localhost.
codex-m wrote:Instead of localhost try testing it on a live site, hosted in a reputable server to see if those email can be sent. It is highly possible they block email addresses originating from localhost.
Hello codex-m!
I couldn't agree the most with you. I think this is the only to way to find out!