Question

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 = "name@domain.com", \"$emailFrom\";

edit: Added new configuration:

$emailHeaders = 'From: "Conference" <noreply@conference.org>' . 'CC: . $emailFrom .';

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

Thanks!

Was it helpful?

Solution

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

for example:

$headers = 'From: Family History Conference <noreply@familyhistoryconference.org>' . "\r\n" .
    'Reply-To: noreply@familyhistoryconference.org' . "\r\n" .
    'CC: ' . $emailFrom . "\r\n";

and then

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

References:

OTHER TIPS

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

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

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('admin@email.com', $subject, $message, $headers);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top