I am trying to creat a php code that sends an automatic email after the user submits there email.
the user will first be on the page with the html form, which is :
they submit there email and then will be sent to a page, sendemail.php, which will send the email and give them confirmation, on the page, that the email was succesfully sent. I keep getting the echo, Message delivery failed..., and i dont know whats wrong. The php code is posted below, can someone help?
the user will first be on the page with the html form, which is :
Code:
<html> <head> <title> Email </title> </head> <body> <center> Please send us your email. You will get a confirmation of your submission sent to your suggested email address. <FORM ACTION="sendemail.php" METHOD="POST"> <INPUT TYPE="TEXT" NAME="email" VALUE="[email protected]" SIZE="25" MAXLENGTH="150"> <p> <INPUT TYPE="SUBMIT" NAME="submit" VALUE="Submit My Email" width="25"> </FORM> </body> </html>
PHP Code:
<?php
$email = $_REQUEST['email'] ;
$to = "$email";
$subject = "Hi!";
$body = "Thank you for visiting something.com. Please visit often as we update weekly! We will have new stuff for you to do often, so subscribe to our mailing list for weekly newsletters. Thanks!";
if (mail($to, $subject, $body)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
?>
Comment