PHP email form won't submit with different entered email address
Any idea why the [Enter email] field on this form will only reach firstname.lastname@example.org if the email entered matches email@example.com?
If I put in any other email address than the one listed in $to=, the email doesn't send.
$fieldname = 'images';
// we'll begin by assigning the To address and message subject
$from = "<".stripslashes($_POST['email']).">";
// generate a random string to be used as the boundary marker
// now we'll build the message headers
$headers = "From: $from\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-Type: multipart/mixed;\r\n" .
If indeed you want the email to appear to come from the address listed in the form, you can't in general do that. You can't send email on behalf of another use (your SMTP server is likely to reject it these days). This is to prevent pfishing attacks (FROM: Someone@ThatYouKnow.com, SUBJECT: What is that password again?).
Send it from an email address that you control. Include the email address from the form as part of the body of the email.
Asked in February 2016Viewed 3,355 timesVoted 7Answered 1 times