Mailed-by Header

software development


So I know this is set by the outgoing server, for obvious purposes. Here’s my question with some quick info as to why. I have all mail from one of my domains forwarding to one address. Just a lot easier than checking many mailboxes per day. If I need to ever reply, I made a simple php script, using mail(). However, the mailed-by line says the server my account is on ( Is there anyway to make that say ( of course being my actual domain, but I didn’t want to just paste it here)? Just makes the email seem a bit phoney, to me at least, if it wasn’t mailed-by your own domain. Know what I mean?

TIA for all the help.


Try this, replacing with the address you want it sent from:

mail($recipient, $subject, $message, $headers, ‘’);

Or replace $headers with null, if you’re not adding any headers.

:stuck_out_tongue: Maximum savings promo code: MaxSavingsAtDH


What exactly does the -f option do in mail? I can use a header to make it seem like it was sent by an address. Will the -f option use the SMTP of the email address I provide?? Or…???


There’s more info here:

Here’s a quote from that page:

:stuck_out_tongue: Maximum savings promo code: MaxSavingsAtDH


While I appreciate the help, and please forgive this, I’m still a bit confused. I’m not trying to ask how to make it so the email says it was sent from (for instance) I can already do that with the header. I’m trying to make it so when you look at all of the information, the mailed-by (which shows the server it was mailed from) doesn’t say, but it says I could definitely be wrong, but it seems the -f option is to set the sender’s envelope address, which I’ve already done in the header. I’m trying to change the “mailed-by” from to If I misinterpretted the -f feature, please let me know.

Edit: What is odd is if I send an email via squirrelmail, I don’t even see the mailed-by in the header. If they don’t include one, there’s got to be a way for me not to include one?


Just an FYI. Our wiki page on the mail() function gives an example that shows you how to set the “from” and “reply to” headers.

Max discount on any plan with promocode SCJESSEYTOTAL


Thanks scjessey, but again, that’s not what my question was. sigh


-f will replace the server name with the email address you enter as the return path. Who it’s sent from will still be whatever you enter in the From: field. Easy - give it a try. :wink:

Just make two test scripts, load each one once to send an email, then compare the headers.

<?php mail('recipient email address', 'subject', 'message', null, '-fyou@email.address'); ?> and

<?php mail('recipient email address', 'subject', 'message'); ?>

:stuck_out_tongue: Maximum savings promo code: MaxSavingsAtDH


That’s why I said “Just an FYI.”

Max discount on any plan with promocode SCJESSEYTOTAL


I see what you mean. However, that also was not my question. I already set the Return-Path header :P. I believe I sort of already answered my question though. It seems that when mail() is used, it includes the server it was mailed from as the “mailed-by” header (not really a header, just above the subject. not really a header as in not user configureable). For instance, when I use squirrelmail, which uses its own implementation of SMTP, it doesn’t show anything from the mailed-by. gmail shows, comcast doesn’t show anything, etc. I believe I simply need to use something else, unless there is some way I can set mail() to use instead of just