This is not spam! GMAIL


When using Media Temple Virtual Dedicated (dv) server – Why does gmail think all email is being sent using PHP mail() is being sent from the primary domain and not other domains host on the same server. Why is google receiving emails that say: Username <> via  I want to get rid of the darn via!


In the gmail help it says you need to sent up SPF and Domainkeys. I set up the SPF and tried again and the email was being authenticated but by the primary domain not the secondary.

I stuggled with this for days, then I relized that when mail was sent by the webmail client on the secondary server it arrived at gmail just fine. So it dawned on me to compare the two email headers.

This can be done by opening the email and next to the reply button is a drop down where you click “Show original”. This will show the message as gmail received it. What I notice was the problem emails had:


And the emails from the secondary domains webmail client had

     Return-Path: <>

When you call mail() in PHP it just calls sendmail on the server and if you don’t tell it the return path it will use by default. Use the code below as a template to send non-spam emails to gmail.

PHP code:

$to = '';
$message = 'This is a test email';
// subject
$subject = 'Sample Email';
// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . PHP_EOL;
$headers .= 'Content-type: text/html; charset=iso-8859-1' . PHP_EOL;
$headers .= 'From: Pupalup ' . PHP_EOL;
$headers .= 'Reply-To:' . PHP_EOL;
$headers .= 'Return-path:' . PHP_EOL;
$headers .= 'X-Mailer: PHP/' . phpversion();
// Mail it
mail($to, $subject, $message, $headers);

Published by

Brian Gaeddert

A hard working quick learner who is an ambitious and self-motivated web developer with a strong technical and design background who possesses self-discipline and the ability to work with the minimum of supervision. A great team player who thrives on creating innovative solutions in a multidisciplinary team, is detail-oriented and has the ability to produce detailed technical specifications from client requirements. A quick learner who can absorb new ideas and communicate quickly and effectively. A high awareness of industry issues and trends, particularly in regard to emerging technologies, website usability/accessibility, mobile solutions, and data integration. Native English speaker with professional proficiency in Spanish.

Leave a Reply

Your email address will not be published. Required fields are marked *