Go Back   Web Server Hosting Forum by BODHost > Support > PHP Forum
 

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 01-03-08, 07:05
BOD Member
 
Join Date: Nov 2005
Location: New Mexico
Posts: 273
Default How to send Mail in PHP

Can anyone suggest me good method of sending emails that are going to email addresses taken from a database.

At present I am using this method -

PHP Code:
while($row=mysql_fetch_array($result))
{
$to = "$row[email]";
$subject = "Title";
$body = "Body Content";
$headers = "From: webmaster@borninblood.co.uk\r\n" .
"X-Mailer: php";
if (mail($to, $subject, $body, $headers)) {
echo("<p>Message sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
}
}

But when this my website goes into 403 error because the server assumes this is a security breech.

Please suggest me proper method.
Reply With Quote
  #2 (permalink)  
Old 01-03-08, 13:42
BOD Member
 
Join Date: Mar 2006
Location: Scotland
Posts: 201
Default

I use this method and have had no problems with it:

while($row=mysql_fetch_row($result)) {
$name=$row[0];
$email=$row[1];
$body="";
$headers=$head . "Content-type: text/html; charset=iso-8859-1" . $eol . $eol;
$body="<p> Dear " . $name . ",</p>";
$body.=$tb;
mail($email, $subject, $tbody, $headers);
echo("<br>sent to " . $email );
$body="";
}

I have left out the unsubscribe link for clarity.

The only single problem I think I might have is some people's newsletters get classed as spam by Yahoo .This isn't a general thing, but it does happen.
And when I look at the headers of my copy sent to me, it's got:

Sender: Nobody <nobody@norway.bodhost.com>

Anyone know a way around this?

I've got:

$head="Reply-To: \"Smallholders Online Newsletter\" <newsletter@smallholders.org>\n";
$head.="Return-Path: <newsletter@smallholders.org>\n";
$head.="From: \"Smallholders Online Newsletter\" <newsletter@smallholders.org>\n";

in the email header.
Reply With Quote
  #3 (permalink)  
Old 01-06-08, 07:06
BOD Member
 
Join Date: Nov 2005
Location: New Mexico
Posts: 273
Default

Thanks Carl,
For this reply I will try this and let you know.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump


All times are GMT -6. The time now is 22:32.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
Copyright © 1999-2012, BODHost Ltd. All rights reserved.