Jump to content

[SOLVED] Email script and adding additional email address to send to???


craigtolputt

Recommended Posts

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';
	}

 

Link to comment
Share on other sites

$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 :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.