From address is same as sender address
Confused. Why is the from address set to the sender address?
Shouldn't this:
$header .= 'From: =?UTF-8?B?' . base64_encode($this->sender) . '?= <' . $this->sender_email . '>' . PHP_EOL;
$header .= 'Reply-To: =?UTF-8?B?' . base64_encode($this->sender) . '?= <' . $this->sender_email . '>' . PHP_EOL;
be more like this:
$header .= 'From: ' . $this->from . PHP_EOL;
$header .= 'Reply-To: =?UTF-8?B?' . base64_encode($this->sender) . '?= <' . $this->sender_email . '>' . PHP_EOL;
Sorry if i've missed something.
Hey this is my first time working with php and i'm trying to use it in a contact form page to send the website owner a email, i'm not sure what the issue is but it wont send the the the email doesn't get sent to the website owner if you can give any advice please let me know thanks 👍
I can send you my snippet later today if you need to see it
@BigBird420 What error have you received? If you haven't received like me, I just change the code like above and started to work.
@aftoledo there are no error messages the site seems to be running the php file fine but it doesn’t send a email to the owners email account
@BigBird420
If your problem is like mine, just change it: $header .= 'From: =?UTF-8?B?' . base64_encode($this->sender) . '?= <' . $this->sender_email . '>' . PHP_EOL; $header .= 'Reply-To: =?UTF-8?B?' . base64_encode($this->sender) . '?= <' . $this->sender_email . '>' . PHP_EOL;
to something like this: $header .= 'From: ' . $this->from . PHP_EOL; $header .= 'Reply-To: =?UTF-8?B?' . base64_encode($this->sender) . '?= <' . $this->sender_email . '>' . PHP_EOL;
@aftoledo when I get home I’ll share my snippet looks different from yours
@aftoledo <?php $name = $_POST['name']; $visitor_email = $_POST['email']; $message = $_POST['message'];
$email_form = '[email protected]';
$email_subject = "New Form Submission";
$email_body = "User Name: $name.\n".
"User Email: $visitor_email.\n".
"User Message: $message.\n";
$to = "[email protected]";
$headers = "form: $email_form \r\n";
$headers .= "Reply-To: $visitor_email \r\n";
mail($to,$email_subject,$email_body,$headers);
header("Location: index.html");
?>
I don't know if it matters, but try to change single to double cotes here: $email_form = '[email protected]';
double and single quotes: https://stackoverflow.com/questions/3446216/what-is-the-difference-between-single-quoted-and-double-quoted-strings-in-php
hey it didnt end up working i just went back and restarted the form by using formspree and javascript thanks though