I'm trying to send emails from my localhost, but I'm running across an issue that keeps coming up. I found this answer which explained how to set up XAMPP to send email, and the emails are sent, but when I try changing the From
header, nothing happens. The email gets sent, but it's sent from my personal email.
I tried removing both the sendmail_from
in php.ini
and force_sender
in sendmail.ini
, but neither worked. I tried adding the -f
parameter to the mail
function, and it didn't work. I've even tried restarting XAMPP several times, but still nothing. Is there something I've overlooked or is there no way to do this?
PHP
<?php
$headers = "From: Joe Smith <joe@joesmith.com>" . "\r\n";
mail("recipient@gmail.com", "This is a test message", "Yup, it's a test message all right.", $headers, "-f joe@joesmith.com");
?>
php.ini
[mail function]
SMTP=smtp.gmail.com
smtp_port=587
sendmail_from =
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
sendmail.ini
[sendmail]
smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=mypersonalemail@gmail.com
auth_password=mypersonalpassword