Sending emails, with a "from" field

i am using the following code:
function Email()
mail( $this->to, $this->subject, $this->message, "")
or print "could not send email";

unfortuantely the "from field deos not work, it just indicates on the recipients email the name of my host...
I want it to use the email address I have passed to it.

In an example I saw ages ago, but have since been unable to find, it seemed to alter the headers or something, but all the examples I have since found only use the example I show above....

Any clues..
Who is Participating?
get a copy of phpmailer, and it comes with an example file ready to go, just put your data instead of the sample data and here we go, a pullet proof mailing application :)
"From: your name <>";

you'd better use phpmailer and use smtp to send your mails, it is much more easier and reliable than mail() function
jdav3579Author Commented:
tried that, it just puts it in the body of the email!!! I am sure it was something to do with setting headers..
with regard to phpmailer and smtp, I have never used this method before so am not sure how to used it.. i will google it though and have a look..
This should work,

mail( $this->to, $this->subject, $this->message, "From:\r\n")

Alternatively, as dr_dedo mentioned, you can download phpmailer from and use that class for your mail functionality. Please post back when you run into problems.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.