: How do I change the default email that my host sends from php mail from in Justhost's C-panel I'm trying to work with sending mail through PHP for the first time and I've done pretty well
I'm trying to work with sending mail through PHP for the first time and I've done pretty well with the exception of one thing. All mail i send is from an email address that ends in "justhost.com" (justhost is hosting my site). I was wondering is anyone could help me change this to a different email address.
P.S.
Here is the php I'm using to send things from:
$to = "example@email.com";
$subject = "Mail Test at ".strftime("%T", time());
$message = "This is a test.";
$from = "Mike <mike@mysitename.com>";
$headers = "From: {$from}rn";
$result = mail($to, $subject, $message, $header);
echo $result ? 'Sent' : 'Error';
(sorry about the spacing I'm not sure how to fix it)
More posts by @Karen161
1 Comments
Sorted by latest first Latest Oldest Best
You're missing the "s" in $header in the mail() function:
$result = mail($to, $subject, $message, $header);
should be
$result = mail($to, $subject, $message, $headers);
Without a proper From header set you'll get the default from address for the server. Correcting this syntax error will solve that problem.
FYI, always develop with error reporting set to show all errors including notices. If you had done this you would spotted this error quickly.
error_reporting(E_ALL);
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.