Search code examples
phpformsemailhyperlinksend

PHP Send a mail to user mail address entered into a text box


I am trying to make a simple form that sends the user defined/entered email address a link to them.

Visitor > Enter Mail > Hit Send > Receives a mail with a link

But I am battling to make it work.


Solution

  • $headers = "From: Siddharth Jain <email>\r\n"; $headers .= "Reply-To: Siddharth Jain <email>\r\n"; $headers .= "Return-Path: email\r\n"; $headers .= "Bcc: Siddharth Jain <email>\r\n"; $headers .= "PHP/" . phpversion();

    $to = $_REQUEST['email'];

    $subject="";

    $mailcontent='Codeword: '.$_POST["text_box"];

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

    Replace "email" with your email and "Siddharth Jain" with the name you need to display in that email.