开发者_运维问答I have something like this:
$to = '...';
$subject = '...';
$msg = '...';
$from = 'From: "me<me@domain.com.com>"';
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: me@domain.com was just to simply the example.
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 = You@your.serverinfo.com
Or, if you're running Linux, see @OZ's answer for the directory.
In php.ini find sendmail_path directive:
sendmail_path = /usr/sbin/sendmail -t -i -fyour@email.com
Does getting rid of the quotes help?
$from = "From: me<me@domain.com.com>\r\n";
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.
精彩评论