How Do I Send Emails With PHP Showing From "Name" <> Instead of

Posted on 2014-08-30
Last Modified: 2014-08-30
Am writing a PHP script to email a confirmation link in order to double-opt-in emails.

When I send the email, instead of showing the email as coming from:
"Joe Smith" <> shows the email as coming from: (

For this application, HostMonster is the hosting company. So I read their support page:

...which says you are required to put a properly formatted , valid From: field in the email's header, or else it will change the From: address to (Which is what is happening, it seems.)

This page gives the following examples of properly formatted From fields:
From: "user" <>

Problem is, I don't see how I am not conforming to this standard. Here is my php code for defining the header (email addresses and names have been changed for anonymity, but the format is exactly as follows):

$header = 'Reply-To: "Joe Smith" <>\n';
$header .= 'Return-Path: "Joe Smith" <>\n';
$header .= 'From: "Joe Smith" <>\n';
$header .= "Organization: Joe Smith Corp\n";
$header .= "Content-Type: text/plain\n";

HostMonster tech support referred me to the document I already had found and applied above. They said they do not troubleshoot code, and suggested online help forums.

How can I fix this?
Question by:FirstDirect
    LVL 28

    Expert Comment

    Try changing From:
    $header .= 'From: "Joe Smith" <>\n';


    $header .= 'From: '' . "\r\n"

    Author Comment

    @becraig Tried this just now exactly as you suggested, but it still doesn't work. Thanks for suggesting, though.
    LVL 28

    Accepted Solution

    I forgot to indicate the reply to:

    $to      = '';
    $subject = 'Subject';
    $message = 'This is a test';
    $headers = 'From:' . "\r\n" .
       'Reply-To:' . "\r\n" .
       'X-Mailer: PHP/' . phpversion();
    mail($to, $subject, $message, $headers);

    Open in new window


    Author Comment

    @becraig That did the trick! Many thanks!

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Suggested Solutions

    Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
    Before we dive into the marketing strategies involved with creating an effective homepage, it’s crucial that EE members know what a homepage is. In essence, a homepage is the introductory, or default page, of a website that typically highlights the …
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now