Jump to content

php mail form send to multiple email addresses


fathernugen

Recommended Posts

<?php
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$dropdown = $_POST['dropdown'];
$formcontent=" From: $firstname \n Surname: $lastname \n Email: $email \n Dropdown: $dropdown";
$recipient = "martin@sittingspiritually.co.uk, siobhan@sittingspiritually.co.uk";
$subject = "Newsletter Sign Up";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
if ( mail($recipient, $subject, $formcontent, $mailheader) ){
header('Location: http://www.sittingspiritually.co.uk/thankyou.php');
} else {
die ("error");
}
?>

 

I have recently created a small snippet of php code for posting mail and it's sweet apart from 1 thing.

 

I have two email addresses in the recipient section. It only sends to the last name in the list.

 

Is this because i have written recipient? Should it be recipients?

 

I need this mail to be delivered to both of the email addresses.

 

I'm sure it's simple for someone with expert knowledge.

 

Thanks in advance for any help.

 

Link to comment
Share on other sites

Is this because i have written recipient? Should it be recipients?

 

it could be $foo for all php cares. It's just variable name.

 

There is no obvious reason why that code shouldn't work. The $recipient string is valid.

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.