Reputation: 55
I have something like this:
$to = '...';
$subject = '...';
$msg = '...';
$from = 'From: "me<[email protected]>"';
mail($to, $subject, $msg, $from);
When I send emails, the "from" field always has Me @my.serverinfo.com
How do I get rid of the server info?
SOLVED Got rid of the extra quote marks. Thanks @Daniel (and others)! I will read more about email headers. Also, I don't want to send anonymous email: [email protected] was just to simply the example.
Upvotes: 2
Views: 5038
Reputation: 5356
You should probably read a bit about the e-mail RFC (2822) and create your own string containing the headers you want to send. It's the first place where you should check out. There you can find if the header you want to send is in the official RFC and then write anything you want inside.
Upvotes: 0
Reputation: 7388
As Daniel mentioned, it's probably an issue with the quotations. As a side bit, if you have access to your PHP configuration, you can change it globally in php.ini
In Windows...
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.yourisp.com
; http://php.net/smtp-port
smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = [email protected]
Or, if you're running Linux, see @OZ's answer for the directory.
Upvotes: 2
Reputation:
In php.ini find sendmail_path directive:
sendmail_path = /usr/sbin/sendmail -t -i [email protected]
Upvotes: 1
Reputation: 7924
Does getting rid of the quotes help?
$from = "From: me<[email protected]>\r\n";
Upvotes: 0