robert4442 Posted May 9, 2007 Share Posted May 9, 2007 I have an email script in php that sents to two email addresses. I need to know how to expand this to send many more than two(Up to 10). Below is the script. This script is activated from another page with a form on it. iT IS ALOS BELOW I would aqppreciate your help. *********************************************************************** <?php $to = trim($_POST['to']); $from = trim($_POST['from']); $subject = trim($_POST['subject']); $message = trim($_POST['message']); $copy = '[email protected]'; //$bcc = "[email protected]"; $send = mail($to,$subject,$message,"FROM: ".$from."\n\rCC: ".$copy); if ($send) { echo "Sent"; } else { echo "Error sending"; } ?> ********************************************************************* <form action='sendmail.php' method='post'> <p> </p> <p><font color="#FF0000"><strong>EMAIL TO ATTORNEY GENERAL JOHN ASHCROFT</strong></font></p> <p>TO: <input type='text' name='to'> <br> FROM: <input type='text' name'from'> <br> SUBJECT: <input type='text' name='subject'> <BR> Enter Message:<br> <textarea name='message'></textarea> <br> <br> <input type='Submit' value='Send Message'> </p> ****************************************************** Link to comment https://forums.phpfreaks.com/topic/50584-email-script/ Share on other sites More sharing options...
otuatail Posted May 9, 2007 Share Posted May 9, 2007 never used the ".$copy); but you could make several statments like $send = mail($to_1,$subject,$message,"FROM: ".$from."\n\rCC: ".); $send = mail($to_2,$subject,$message,"FROM: ".$from."\n\rCC: ".); $send = mail($to_3,$subject,$message,"FROM: ".$from."\n\rCC: ".); $send = mail($to_4,$subject,$message,"FROM: ".$from."\n\rCC: ".); where $to_1 to _4 are individual email address. rCC: ? never used that. $success = mail($to,$sss, $mmm, $headers); Link to comment https://forums.phpfreaks.com/topic/50584-email-script/#findComment-248659 Share on other sites More sharing options...
chronister Posted May 9, 2007 Share Posted May 9, 2007 Maybe take otuatail's advice and combine with a loop and loop through all email addresses you want to send to. This may take a few extra moments to process, but it could work. Link to comment https://forums.phpfreaks.com/topic/50584-email-script/#findComment-248689 Share on other sites More sharing options...
mmarif4u Posted May 9, 2007 Share Posted May 9, 2007 The easy way for this add many as u want to ur $to variable separating it using , Like: $to="[email protected]","[email protected]"; and so on. Link to comment https://forums.phpfreaks.com/topic/50584-email-script/#findComment-248694 Share on other sites More sharing options...
mmarif4u Posted May 9, 2007 Share Posted May 9, 2007 Or: $to = '[email protected]' . ', '; // note the comma $to .= '[email protected]' . ', '; $to .= '[email protected]'; And so on u can add as many u want. this is another way to send multiple emails. Link to comment https://forums.phpfreaks.com/topic/50584-email-script/#findComment-248697 Share on other sites More sharing options...
robert4442 Posted May 10, 2007 Author Share Posted May 10, 2007 otuatail, Is this what yopu mean? <?php $to = trim($_POST['to']); $from = trim($_POST['from']); $subject = trim($_POST['subject']); $message = trim($_POST['message']); $send = mail($to_1,$subject,$message,"FROM: ".$from."\n\rCC: ".); $send = mail($to_2,$subject,$message,"FROM: ".$from."\n\rCC: ".); $send = mail($to_3,$subject,$message,"FROM: ".$from."\n\rCC: ".); $send = mail($to_4,$subject,$message,"FROM: ".$from."\n\rCC: ".); if ($send) { echo "Sent"; } else { echo "Error sending"; } ?> What do I do with this? $success = mail($to,$sss, $mmm, $headers); Link to comment https://forums.phpfreaks.com/topic/50584-email-script/#findComment-249971 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.