phpemailgmailaol

Proper formatting of "from" in php mail() function


I want to have the "From" part of a php generated email be just from the company name. Apparently that makes spam filters sad. So, my code is...

$mail->FromName = 'Company Name <some_email@domain.com>';

My issue is that gmail and aol keep returning these emails and the from part looks like this...

From: "Company Name <some_email@domain.com>" <>

Any thoughts about the "<>" at the end?


Solution

  • The <>at the end of "Company Name <some_email@domain.com>" <> indicates that the address is interpreted as containing only the associated name part,with no real email address.

    Try generating the From address as 'Company Name' <some_email@domain.com> or as some_email@domain.com (Company Name)

    Edit: Another possible reason for this problem is that your mailer is using separate fields for the name part and the address part of the From header. If so:

    $mail->From = "some_email@domain.com";
    $mail->FromName = "Company Name"; 
    

    should solve the problem.