Emails appear as an attachment in GMail

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
amir
Forum Contributor
Posts: 287
Joined: Sat Oct 07, 2006 4:28 pm

Emails appear as an attachment in GMail

Post by amir »

Hi! Here is a function that is used to send out emails:

Code: Select all

function send_email($message, $subject, $from_name, $from_email, $to_name, $to_email, $content_type="text"){
          $headers  = "MIME-Version: 1.0\r\n";
          $headers .= "Content-type: $content_type;\r\n";
          $headers .= "From: \"".$from_name."\" <".$from_email.">\n";
          $headers .= "Return-Path: \"".$from_name."\" <".$from_email.">\n";          
          $to = "\"".$to_name."\" <".$to_email.">";
          mail($to, $subject, "$message", $headers);
     }
When a recipient has a gmail account, he receives a text of an email not as inline text, but as an attachment. To view the email he needs to download the attachment and open it in a text editor. The users check their emails through the web. What is wrong with the function and how I can fix it

Thank you!
User avatar
dude81
Forum Regular
Posts: 509
Joined: Mon Aug 29, 2005 6:26 am
Location: Pearls City

Post by dude81 »

Code: Select all

print $content_type
and let us know
amir
Forum Contributor
Posts: 287
Joined: Sat Oct 07, 2006 4:28 pm

Post by amir »

text
Post Reply