PHP mail() to fetch email addresses from a database to send emails out!

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

 



Hi,

After alot of reading of the PHP.net site and other
sites I am using this code below.  I'll explain the
files the code is in and my question below:

---email.php (code to send via mail())---

<?php 
    $i = 0;  
    mysql_connect("localhost", "usr", "pass"); 
    mysql_select_db("tassie_tipping"); 
    $query = "SELECT email FROM tipping"; 
    $result = mysql_query($query) or die("ERROR WHILE
COLLECTING EMAIL ADDRESSES"); 
    while(list($email) = mysql_fetch_row($result)) { 
    $filename = "emails.php"; 
    $fp = fopen($filename,"r"); 
    $data = fread($fp,filesize($filename)); 
    $data .= "<INPUT TYPE=HIDDEN VALUE=$Receiver
NAME=WHOIS>"; 
    $subject = "New Email Program"; 
    $headers = "From:
tipping@tassiedemononline.org.au\n";  
    $headers .= "Reply-To:
tipping@tassiedemononline.org.au\n";  
    $headers .= "Organization: Tassie Demon Online
Tipping Competition\n";  
    $headers .= "Content-Type: text/html;
charset=iso-8859-1\n";  
    mail($email, $subject, $data, $headers); 
    $i = $i + 1; 
    }  
    print("$i emails have been sent!"); 
    ?> 

---emails.php (this is the email to be sent)---

Hi blah ra....

Now the code works fine but I want the following
addition.

I was the email to say:

To [your name],

Welcome to our site, enjoy your stay.

Regards,
Whoever

How would I get the users name from the database to
display in the email?  The names would need to do a
match with the email field somehow.  Can someone
shread some light onto this and hopefully help me on
how I can get it to be displayed.

In finishing please remember I am using 2 PHP pages, 1
is the code that fetches the address and the headers
etc and the second page is the actual email message. 
Would I need to add the code to page 1 or 2?

Thanks for your help in advance.

Jerry

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


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

  Powered by Linux