PHP mail fetching email address(es) from database question!

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

 



Hi,

Fristly, thanks Jen for your information earlier.  I
have managed to fetch email addresses from a database
to be sent out via email fine.  But I have a few
problems which are listed below.

1) I can't get from to work at all.  :(  When the
emails are generated it goes out as nobody @ domain. 
I have tried putting $HEADERS .= email but it fails
badly.  Any idea why?  (the emails go out fine with
the message to all people in the database)

2) I have not managed to find out how to put their
first name at the top of the message.  e.g. to bob,
... I have thought of a few ways, have not tried it
yet.  But would be in the mysql function before it
closes and could be legnthy.. I'd prefer to have it
like a single line and further down have the message. 
At the pressent time I type a message in a form from
the browser with the subject.  Even if I had from on
that form also to input is fine but I can't get it to
work. :(  

The code is below.  Quite easily achieved in the end. 
All help is mostly appreicated.

Thanks in advance.

Jerry



<?php

if(empty($SEND)){$SEND="";}

switch($SEND){
        case "Send":
                if(!empty($MESSAGE)){
                        $HEADERS  .= "MIME-Version:
1.0";
                        $HEADERS .= "Content-type:
text/html; charset=iso-8859-1";

                        /* This script is based on
pulling email addresses from a MySQL user database The
code below
should be changed to the appropriate information */


                        $linkID =
mysql_connect(localhost, usr, password);
                        mysql_select_db(db, $linkID);

                        $obRS = mysql_query("SELECT
email FROM tipping", $linkID);

                        while($row =
mysql_fetch_row($obRS)){
                                foreach ($row as
$field){
                                        mail($field,
$SUBJECT, $MESSAGE, $HEADERS);
                                        print "Message
sent to: <b>$field</b><br>";


}
}

                        mysql_close($linkID);
                        print "<hr><b>MESSAGE
DETAILS</b><hr>";
                        print "<b>From: </b>
$FROM<br>";
                        print "<b>Subject:</b>
$SUBJECT<br>";
                        print
"<b>Message:</b><p>$MESSAGE";
                }
                break;
        case "Preview":
                print "<TABLE BORDER=1 CELLSPACING=0
WIDTH=100% ><TR><TD VALIGN=TOP>$MESSAGE</TD>";
                print "<TD VALIGN=TOP><FORM
ACTION=mail.php  METHOD=POST NAME=FORM1 >";
                print "<B>SUBJECT: </B><Input
TYPE=TEXT NAME=SUBJECT VALUE='$SUBJECT' ><BR>";
                print "<TEXTAREA NAME=MESSAGE
STYLE='width:500;height:300' WRAP=off 
>$MESSAGE</TEXTAREA><BR>";
                print "<INPUT TYPE=SUBMIT
VALUE=Preview NAME=SEND > <INPUT TYPE=BUTTON
ONCLICK='document.FORM1.MESSAGE.value=$
                print "</FORM></TD></TR></TABLE>";
                break;
        default:
                print "<FORM ACTION=mail.php 
METHOD=POST NAME=FORM1 >";
                print "<B>SUBJECT: </B><Input
TYPE=TEXT NAME=SUBJECT VALUE='' ><BR>";
                print "Please type in html code
below.<BR>";
                print "<TEXTAREA NAME=MESSAGE
STYLE='width:500;height:300' WRAP=off 
></TEXTAREA><BR>";
                print "<INPUT TYPE=SUBMIT
VALUE=Preview NAME=SEND > <INPUT TYPE=BUTTON
ONCLICK='document.FORM1.MESSAGE.value=$
                print "</FORM>";
}

?>


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