Jump to content

simple auto respond


bubbafunk1

Recommended Posts

I have a form that when a user enters their email address and hits send an email is sent to their email address. I know how to send the reply to a predefined email address, but i want the email to be sent to the address in the $email = $_REQUEST['email'];

 

here is my code in sendmail.php so far:- even though it does not work properly...... any help would be greatly appreciated.

 

<?php

 

$email = $_REQUEST['email'];

$subject = "Your instant discount code";

$headers = "Reply-To: [email protected]\r\n";

$headers .= "Return-Path: [email protected]\r\n";

$headers .= "MIME-Version: 1.0\r\n";

$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

$message = "<html><body>  Thank you for applying for an INSTANT DISCOUNT CODE. \n\n 1a2b3c4d5e \n\n is your discount code, please type it using lowercase letters at the checkout \r\n Thanks The Team <body></html>";

 

mail ("$email", "$headers" , "$message", "from: The Team");

 

if ( mail($email,$subject,$message,$headers) )

{

header ("location: http://www.mydomain.co.uk/success.htm");

}

else

{

header ("location: http://www.mydomain.co.uk/failed.htm");

}

?>

 

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/195905-simple-auto-respond/
Share on other sites

I know how to send the reply to a predefined email address, but i want the email to be sent to the address in the $email = $_REQUEST['email'];

 

Can you tell what the difference is between:

1) a predefined email address

2) the address in the $email = $_REQUEST['email'];

 

 

Link to comment
https://forums.phpfreaks.com/topic/195905-simple-auto-respond/#findComment-1029060
Share on other sites

1) a predefined email address would be when an email address is written in the code like this - mail ("[email protected]", "$headers" , "$message", "from: The Team");

2) the address in the $email = $_REQUEST['email']; would be the email address that the user has put in the html form, their own email address. So when they press send the php code will take their email address from the $email = $_REQUEST['email']; and send an email right back to them.

 

I have tried inserting $email into the code like so - mail ("$email", "$headers" , "$message", "from: The Team"); but it does not work...

 

 

Link to comment
https://forums.phpfreaks.com/topic/195905-simple-auto-respond/#findComment-1029189
Share on other sites

mail ("$email", "$headers" , "$message", "from: The Team"); should be:

 

<?php
//your other code here

$headers = "Reply-To: [email protected]\r\n";
$headers .= "Return-Path: [email protected]\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers .= "From: [email protected]\r\n";

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

?>

 

Also, your if statement will cause the email to be sent twice.

Link to comment
https://forums.phpfreaks.com/topic/195905-simple-auto-respond/#findComment-1029223
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.