Php Mail Script

Associate
Joined
13 Nov 2003
Posts
1,567
Location
Manchester
Hi All

I am working on a php based mail out script.

Im having all sorts of problems lol, and wondered if you guys could steer me on the right path

Here is the code
Code:
<?php require_once('../Connections/essential.php');

mysql_select_db($database_essential, $essential);
$eventsquery = "SELECT email FROM newsletter_users";
$result = mysql_query($eventsquery);
$num = mysql_num_rows($result);
for ($i = 0; $i < $num; $i++){

$arr[$i] = mysql_fetch_array($result);


@extract($_POST);
$subject = stripslashes($subject);
$fromemail = stripslashes($fromemail);
$content = ($content);
foreach ($arr[$i] as $email) {
$mailto = $email;
$mailsubject = 'Feedback from Essential Manchester.com';
$mailheaders .= "From: $name <$email>\r\n";
$mailheaders .= "Reply-To: $email\r\n";
$mailheaders .= "Return-Path: $email\n";
$message .= " 
$content //n
//n
To unsubscribe from the Essential Newsletter please click 
";
mail($mailto,$mailsubject,$message,$mailheaders);

}




 } ?>

The first problem is that it seems to be sending each name in the database mutliple emails, it should only send the email to each person once.
Secondly, the mail headers are being included in the email when I send it to one of my test accounts.

Also, I need to be able to send the emails as html, how can I do that with this script

Thanks Guys
Aaron
 
I cant get it to work lol. If anyone could rewrite that little block of code to do what I need then it would hugely appreciated and I would owe you one lol

Aaron
 
Getting there lol

Still getting duplicate messages, and duplicate content in the second message it sends to each person.

Also, why would the headers be appearing in the body of the email on one email account?

Thanks Guys
Aaron
 
Hi Rob

I will be adding a link to an unsubdcribe page when its finished that removes them from the DB

The page is authenticated higher up and its also in a protected dir.

I think it will need staggering as the list contains 6800 unique emails at the moment.

I was going to use a ready made script, but none that I tried had the option to send email, and I also need to be able to send a test message to myself first.

Thanks for the help guys, lifesavers as ever lol
Aaron
 
Hey Rob

That script is almost perfect, thanks. The only problem I am having is that the headers are being sent out more than once to some users, so they are appearing in the body of the email.

Any ideas?
Thanks
Aaron
 
Back
Top Bottom