Sending emails, with a "from" field

Hi,
i am using the following code:
function Email()
{
mail( $this->to, $this->subject, $this->message, "email@mywebaddress.com")
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..
Cheers.
John
jdav3579Asked:
Who is Participating?
 
dr_dedoCommented:
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 :)
0
 
dr_dedoCommented:
try
"From: your name <email@mywebaddress.com>";

you'd better use phpmailer and use smtp to send your mails, it is much more easier and reliable than mail() function
0
 
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..
cheers
0
 
RoonaanCommented:
This should work,

mail( $this->to, $this->subject, $this->message, "From: email@mywebaddress.com\r\n")

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

-r-
0
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.