note 54928 added to function.mail

From: Date: Tue, 19 Jul 2005 21:21:38 +0000
Subject: note 54928 added to function.mail
Groups: php.notes 
Request: Send a blank email to php-notes+get-92187@lists.php.net to get a copy of this message
When you want to sent mail to emailadresses that you've got stored in a database, one can use this code (at least it's been usefull to me ;): // fetch adresses from database while ($emailadresses = mysql_fetch_array($query, MYSQL_ASSOC)) { foreach ($emailadresses as $oneMailadres) { $recepients .= "$oneMailadres"; //build up the recepient string $recepients = $recepients . ", "; } } // this is the tricky part: mail() will not sent to all the emailadresses, if you let your string end with ', ', so I used substr() to remove the last two characters from the string (comma and space). $recepients = substr($recepients, 0, -2); //actual sending mail($recepients, $subject, $mailbody, "From: $senderAddress"); ---- Manual Page -- http://www.php.net/manual/en/function.mail.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+54928 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54928&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54928&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54928&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54928&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54928&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54928&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+54928&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#92187) next »