RE: PHP mail() question?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



mmm, could you use a foreach loop?
I think you will need to send separate mail items for each e-mail
address you have stored in the database if you want to address it to
them personally.

Eg in seudo code:
foreach($row_returned_from_database){
  # variables & headers etc here
  # eg, $contactemail = $row['email']
  mail($contactemail, $subject, $message, $headers);
}


Cheers,
Gav



-----Original Message-----
From: JeRRy [mailto:jusa_98@yahoo.com] 
Sent: Tuesday, 1 April 2003 9:05 AM
To: php-db@lists.php.net
Subject:  PHP mail() question?


Hi,

I am trying to get PHP mail() to do the following:

1) Grab email addresses from a database and put in the
BCC of the email. (hidding their email address)

2) Grab first names from a database and put in the
body of the email.

Below is a script I am using, does not do any queries
to any database because I am not sure how to do it in
the function.  I have tried but have failed so thought
I'd ask here.  Can anyone help?  Here is the code I am
using...  

<?php

$myname = "Me Myself"; 
$myemail = "myself@email.com"; 

$contactname = "Mister Contact"; 
$contactemail = "whateva@domain.com"; 

$message = "hello from ".$contactname.""; 
$subject = "A email"; 

$headers .= "MIME-Version: 1.0\r\n"; 
$headers .= "Content-type: text/html;
charset=iso-8859-1\r\n"; 
$headers .= "From: ".$myname." <".$myemail.">\r\n"; 
$headers .= "To: ".$contactname."
<".$contactemail.">\r\n"; 
$headers .= "Reply-To: ".$myname."
<$myreplyemail>\r\n"; 
$headers .= "X-Priority: 1\r\n"; 
$headers .= "X-MSMail-Priority: High\r\n"; 
$headers .= "X-Mailer: Just My Server"; 

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

?>

Maybe I need a different function? If so could someone
show me a example of how it can be achieved please? 

Thanks!

Jerry

P.S. I am using mysql database.

http://mobile.yahoo.com.au - Yahoo! Mobile
- Check & compose your email via SMS on your Telstra or Vodafone mobile.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux