views:

37

answers:

3

I am using a simple HTML form for an event registration and I would like to send a PHP confirmation email to the registrant with the same information that is going to the administrator.

Here are the details:

$emailFromName = $_POST['name'];
$emailFrom = $_POST['email'];
$emailFromPhone = $_POST['phone'];

I would like to use the value from $emailFrom in the following email address to:

$emailTo = "[email protected]", \"$emailFrom\";

edit: Added new configuration:

$emailHeaders = 'From: "Conference" <[email protected]>' . 'CC: . $emailFrom .';

This obviously doesn't work, but you get the idea of what I am trying to.

Thanks!

A: 

You will need to add headers to the mail function...

for example:

$headers = 'From: Family History Conference <[email protected]>' . "\r\n" .
    'Reply-To: [email protected]' . "\r\n" .
    'CC: ' . $emailFrom . "\r\n";

and then

mail($to, $subject, $message, $headers);

References:

Garis Suero
Would this be correct? $emailHeaders = 'From: "Family History Conference" <[email protected]>'; $emailHeaders = 'Cc: ' . $emailFrom . "\r\n";
fmz
See edited answer... Added your mails as you have to use it...
Garis Suero
Please always refer to the Language documentation...
Garis Suero
A: 

You put "From: $name <$emailFrom>" in the additional parameters of the mail() function:

http://php.net/manual/en/function.mail.php

handsofaten
A: 

So, basically you want to CC a copy of the message to the user as well as the administrator?

It depends on which PHP library you're using to send it. If you're using the default PHP mail() function, you'll need to add additional headers:

// Additional headers
$headers .= 'Cc: ' . $emailFrom . "\r\n";

// Mail it
mail('[email protected]', $subject, $message, $headers);
Jack Webb-Heller
Like this? $emailTo = "[email protected]"; $subject = "Conference Registration"; $headers .= 'Cc: ' . $emailFrom . "\r\n";
fmz
Hi Jack. Please take a look at the edited code at the top. Is that correct for adding cc to the header info? Thanks.
fmz