[Last Call] Learn how to a build a cloud-first strategyRegister Now


Sending emails, with a "from" field

Posted on 2006-05-26
Medium Priority
Last Modified: 2008-02-26
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..
Question by:jdav3579
  • 2
LVL 16

Expert Comment

ID: 16771572
"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

Author Comment

ID: 16771618
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..
LVL 16

Accepted Solution

dr_dedo earned 375 total points
ID: 16771679
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 :)
LVL 49

Expert Comment

ID: 16771920
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.


Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
This article discusses how to implement server side field validation and display customized error messages to the client.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question