craigtolputt Posted September 30, 2009 Share Posted September 30, 2009 Hi Guys, I have an online form which sends an email detailing the users request. There is a drop down box with 4 options and depending on what the user chooses it will send the email to a different email address. so for example if they choose Weddings then the email gets sent to weddings@ and if they choose Business then the email gets sent to sales@. What i need to do is also send a copy of the email to info@ aswell. heres my code: if($interest == 'Membership'){ $address = 'membership@myemail.co.uk'; } else if($interest == 'Events'){ $address = 'sales@myemail.co.uk'; } else if($interest == 'Business'){ $address = 'sales@myemail.co.uk'; } else if($interest == 'Weddings'){ $address = 'weddings@myemail.co.uk'; } can i just do this: if($interest == 'Membership'){ $address = 'membership@myemail.co.uk' && 'info@myemail.co.uk'; } else if($interest == 'Events'){ $address = 'sales@myemail.co.uk' && 'info@myemail.co.uk'; } else if($interest == 'Business'){ $address = 'sales@myemail.co.uk' && 'info@myemail.co.uk'; } else if($interest == 'Weddings'){ $address = 'weddings@myemail.co.uk' && 'info@myemail.co.uk'; } Quote Link to comment https://forums.phpfreaks.com/topic/176029-solved-email-script-and-adding-additional-email-address-to-send-to/ Share on other sites More sharing options...
trq Posted September 30, 2009 Share Posted September 30, 2009 can I just do this: No, but you could do.... $address = 'membership@myemail.co.uk, info@myemail.co.uk'; Quote Link to comment https://forums.phpfreaks.com/topic/176029-solved-email-script-and-adding-additional-email-address-to-send-to/#findComment-927532 Share on other sites More sharing options...
Yesideez Posted September 30, 2009 Share Posted September 30, 2009 $address=''; switch ($interest) { case 'Membership': $address='membership@myemail.co.uk'; break; case 'Events': $address='sales@myemail.co.uk'; break; case 'Business': $address='sales@myemail.co.uk'; break; case 'Weddings': $address='weddings@myemail.co.uk'; break; } if (!empty($address)) { mail($address,$subject,$message,$headers); } mail('info@myemail.co.uk',$subject,$message,$headers); That way the email will only get sent to those in the switch statement if one of the cases match and an extra email will always be sent to info. EDIT: thorpe's got a much better idea Quote Link to comment https://forums.phpfreaks.com/topic/176029-solved-email-script-and-adding-additional-email-address-to-send-to/#findComment-927534 Share on other sites More sharing options...
craigtolputt Posted September 30, 2009 Author Share Posted September 30, 2009 nice one thanks guys. Quote Link to comment https://forums.phpfreaks.com/topic/176029-solved-email-script-and-adding-additional-email-address-to-send-to/#findComment-927535 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.