pioneerx01 Posted January 11, 2011 Share Posted January 11, 2011 Hi, I have this email code working for me: $headers1 = "From: [email protected]\r\n"; $headers1 .= "BCC: [email protected]\r\n"; $to1 = $_GET['e1'].", ". $_GET['e2'].", ". $_GET['e3'].", ". $_GET['e4']; mail($to1, " my subject line", " my message here ", $headers1); In the forms users can submit up to 4 independent email addresses (but are not required to do so) in any combination. This email from works only if email address 1 and 4 are entered. Other can be entered too, but if 1 and 4 are not there email does not go out. I sort of understand why, but I can not figure out a way around it and I do not want to split to 4 independent email codes. Any help on this one? Thanks Link to comment https://forums.phpfreaks.com/topic/224119-trouble-with-this-email-code/ Share on other sites More sharing options...
taquitosensei Posted January 11, 2011 Share Posted January 11, 2011 try this for($a=1;$a<=4; $a++) { $glue=($a>0)?", ":""; $to1.=($_GET['e'.$a]!='')?$glue.$_GET['e'.$a]:""; } Link to comment https://forums.phpfreaks.com/topic/224119-trouble-with-this-email-code/#findComment-1158083 Share on other sites More sharing options...
pioneerx01 Posted January 12, 2011 Author Share Posted January 12, 2011 I see what you did there, but it did not really work for me. Link to comment https://forums.phpfreaks.com/topic/224119-trouble-with-this-email-code/#findComment-1158248 Share on other sites More sharing options...
taquitosensei Posted January 12, 2011 Share Posted January 12, 2011 It's probably because I put $a>0 and it should be 1 for($a=1;$a<=4; $a++) { $glue=($a>1)?", ":""; $to1.=($_GET['e'.$a]!='')?$glue.$_GET['e'.$a]:""; } Link to comment https://forums.phpfreaks.com/topic/224119-trouble-with-this-email-code/#findComment-1158429 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.