[PHP-DB] php mail() question
Hi, Php mail() question. I use php mail() frequently, dragging data from a mysql database. I am not sure if this is possible but thought I'd throw it on this board. in php mail() function you can set a return_address etc. Is it possible to change this and run a query? I mean if the email bounces can it somehow talk back to php mail() and do a query rather than send it to the return_address? Thanks! http://personals.yahoo.com.au - Yahoo! Personals New people, new possibilities. FREE for a limited time. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] PHP mail() question?
function htmlemailheaders($from=somename[EMAIL PROTECTED],$CC=,$BCC=){ //three arguments, last two optional // http://www.mindspring.com/~mgrand/mime.html voor mime specificaties $mailheaders = NULL;//initi $mailheaders .= From: $from\r\n;//waarde van eerste argument van de functie $mailheaders .= Reply-To: $from\r\n; //$mailheaders .= Return-Path: $from\r\n; //$mailheaders .= Return-Receipt-To: $from\r\n; $mailheaders .= MIME-Version: 1.0 \r\n; // $mailheaders .= X-Mailer: Register PHP by DPDK\r\n; //mailer $mailheaders .= X-Priority: 3\r\n; //1 UrgentMessage, 3 Normal $mailheaders .= Content-type: text/html;charset=us-ascii \r\n;//charset=iso-8859-1 $mailheaders .= Content-Transfer-Encoding: 7bit \r\n; //add more headers if($CC!=) { $mailheaders .= Cc: $CC\r\n;//tweede argument, alleen toevoegen als er een waarde voor is } if($BCC!=) { $mailheaders .= Bcc: $BCC\r\n;//derde argument, BCC altijd achteraan de headers } return $mailheaders;//function returns the headers, either store them in variable or use in php mail() function }//end function htmlemailheaders()- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] PHP mail() question?
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:[EMAIL PROTECTED] Sent: Tuesday, 1 April 2003 9:05 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] 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 = [EMAIL PROTECTED]; $contactname = Mister Contact; $contactemail = [EMAIL PROTECTED]; $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
[PHP-DB] 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 = [EMAIL PROTECTED]; $contactname = Mister Contact; $contactemail = [EMAIL PROTECTED]; $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
RE: [PHP-DB] PHP mail() question?
mail() will not run queries, you need to look at the php manual for the set of functions for the database type you plan on using and execute the database stuff in your script and pass the formatted results in the appropriate argument of the mail function. ie $con = mysql_connect($host, $user,$pw); $query = SELECT Email from EmailDatabse.TableToUse Where criteria = 'clause'; $result = mysql_query($query); while ($row = mysql_fetch_array($result)){ $bcc .= $row[Email].,; } $bcc = substr($bcc 0, -1); //getting rid of last comma $headers .= bcc: $bcc\r\n; This is just a quick example, you'll need to add error checking and make sure the argument order is correct on the functions, I don't have time to, but I thought I'd at least put an effort into sending you on your way to getting a functioning script. -Original Message- From: JeRRy [mailto:[EMAIL PROTECTED] Sent: Monday, March 31, 2003 3:05 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] 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 = [EMAIL PROTECTED]; $contactname = Mister Contact; $contactemail = [EMAIL PROTECTED]; $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
[PHP-DB] php mail() question?
Hi, I am using a 'basic' PHP mail() function that works fine when inputting data and information for it to send. But now I want to do the following: 1) Fetch email addresses from a mysql database and put them as Bcc: so emails are always hidden. Or some other method? (would be ideal to have the recievers email as the to: when they read it but only theirs.) 2) Grab their first name from the mysql database and put that as the first line in the body. (e.g. Dear bob,) Could someone give me a example on how this would work? Does not need to be complex just needs to show me the functions and where what goes. I have tried a few techniques but have failed so thought I'd post here. Thanks 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