Friday, September 19, 2008

Edit or remove 'signed-by' or 'mailed-by'

Recently I was trying to remove the labels 'signed-by' or 'mailed-by' which displayed the server name of my web hosting company when I do mailing activities from PHP script.

I was actually wanted to have my domain or perhaps my 'fake' domain address to be there. I don't want to display the web hosting company.

The labels are like distracting me as a mailer, because I don't really need that to be displayed. They're like disturbing my privacy.

After having some research, I finally found the answer. There's actually five arguments in the mail() function, instead of just four like this:

mail($mailto,$subject,$message,$header);
The fifth argument is the answer to my question. I believe some of you might get in the same situation.

So lets get straight to the point. Choose one of these below:
  1. You want your domain to be displayed; or
  2. You want nothing to be displayed.
You can't have them to display other than that. I.e: You want it to display 'signed-by: google.com' or 'mailed-by: yahoo.com'. No you can't have it. Just choose one of the stated above.

If you want the first choice, do this:
  1. Create an email address from your domain, or take one you've had, like admin@yourdomain.com.
  2. Set your code like this:
    mail($mailto,$subject,$message,$header,'-f admin@yourdomain.com');
  3. There's no number 3, you're done!
If you want the second choice, you only have to do the second one in the first choice. You may change the 'admin@yourdomain.com' to any email you'd like, i.e: myself@yahoo.com.

Easy, huh?

8 comments:

MisterTim said...

Hi Imam
It does look easy, but you didn't say really where the "code" was to be changed. (and no..I'm not upset you declined my advert ;-)
Tim

ImamKhalid said...

Hi, Tim.

It is indeed easy. As far as I'm concerned, I'm not talking about the code.

I'm talking about a technique that we could use in order to edit or to remove the distracting label when we use mail() function in our code (programming).

Never mind, Tim. I'll elaborate more about this in more detail, soon. ;)

ImamKhalid said...

Oops, sorry I forgot to tell you, Tim. I'm very sorry for declining your advert, but I'm actually not yet ready to accept any advert for that particular time.

P/s: But now I'm ready! ;)

Anonymous said...

The give is wrong, any one paste the correct code,

thanks

ImamKhalid said...

It's not wrong. You must have made a mistake somewhere. Please let me know how may I help you. ;)

Big I said...

awesome post, so simple, so concise, thank you for sharing!

prez jordan said...

Hm, when I try and send an email with another parameter after headers, nothing happens.

Not working for me.

ImamKhalid said...

What do you mean nothing? Have you checked the mailed-by or signed-by, before and after the parameter added?