Mailed-by Header

Mailed-by Header

Posted by: OrGoN3
Posted on: 2008-01-30 18:41:00

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 (federal.dreamhost.com). Is there anyway to make that say mydomain.com (mydomain.com 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.

Re: Mailed-by Header

Posted by: seiler
Posted on: 2008-01-30 22:10:00

Try this, replacing you@example.com with the address you want it sent from:

mail($recipient, $subject, $message, $headers, '-fyou@example.com');

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

Re: Mailed-by Header

Posted by: OrGoN3
Posted on: 2008-01-30 22:14:00

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...???

Re: Mailed-by Header

Posted by: seiler
Posted on: 2008-01-30 22:21:00

There's more info here: http://us3.php.net/manual/en/function.mail.php.

Here's a quote from that page:

In reply to:


The additional_parameters parameter can be used to pass an additional parameter to the program configured to use when sending mail using the sendmail_path configuration setting. For example, this can be used to set the envelope sender address when using sendmail with the -f sendmail option.

The user that the webserver runs as should be added as a trusted user to the sendmail configuration to prevent a 'X-Warning' header from being added to the message when the envelope sender (-f) is set using this method. For sendmail users, this file is /etc/mail/trusted-users.


Re: Mailed-by Header

Posted by: OrGoN3
Posted on: 2008-01-31 00:17:00

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) user@mydomain.com. 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 federal.dreamhost.com, but it says mydomain.com. 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 federal.dreamhost.com to mydomain.com. 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?Edited by OrGoN3 on 01/31/08 00:23 AM (server time).

Re: Mailed-by Header

Posted by: scjessey
Posted on: 2008-01-31 04:10:00

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.

-- si-blog --

Re: Mailed-by Header

Posted by: OrGoN3
Posted on: 2008-01-31 11:57:00

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

Re: Mailed-by Header

Posted by: seiler
Posted on: 2008-01-31 12:36:00

-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');
?>


Re: Mailed-by Header

Posted by: scjessey
Posted on: 2008-01-31 12:48:00

In reply to:

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


That's why I said "Just an FYI."

-- si-blog --

Re: Mailed-by Header

Posted by: OrGoN3
Posted on: 2008-01-31 19:55:00

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 gmail.com, 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 mail.mydomain.com instead of just federal.dreamhost.com.

Tags: outgoing servermailphp scriptmailboxesemailoutgoing servermailphp scriptmailboxesemail