Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-23-2008, 12:12 AM   PM User | #1
pinkshiro
New Coder

 
Join Date: Mar 2005
Posts: 85
Thanks: 3
Thanked 0 Times in 0 Posts
pinkshiro is an unknown quantity at this point
My Mail Headers aren't working

Hi Everyone,

I have set up a form which on submit, sends off an email to the client with a plain text version in the body and an HTML file attached to the email.

But they are not receiving the email. They are using Mail Marshal, and it is blocking my forms emails from getting through. However, my own domain is letting them through fine...as is hotmail & my ISP's email.

I am assuming I have messed up the headers for the mail function. Can you please take a look at my headers and tell me if I have messed up. I am fine with basic headers, but when we include attachments, that's when I start getting lost. So any help would be appreciated. Cheers.

Please note that I have removed the domain name and replaced with "testdomain"

PHP Code:
$mailSubj     'New Assessment - '.date('d/m/Y 'time()).' Test Email ';

    
$fileatt $location// Path to the file
    
$fileatt_type "application/octet-stream"// File Type
    
$fileatt_name "assessment.html"// Filename that will be used for the file as the attachment
    
    
$email_from "web@testdomain.com"// Who the email is from
    
    
$email_message $mailBody// Message that the email has in it
    
    
$email_to "admin@testdomain.com"// Who the email is too
    
    
$headers "From: Test company <".$email_from.">\n";
    
$headers .= "Bcc: test@testdomain.com\n";
    
    
$semi_rand md5(time());
    
$mime_boundary "==Multipart_Boundary_x{$semi_rand}x";
    
    
$headers .= "MIME-Version: 1.0\n" .
    
"Content-Type: multipart/mixed;\n" .
    
" boundary=\"{$mime_boundary}\"";
    
    
$email_message .= "This is a multi-part message in MIME format.\n\n" .
    
"--{$mime_boundary}\n" .
    
"Content-Type:text/plain; charset=\"iso-8859-1\"\n" .
    
"Content-Transfer-Encoding: 7bit\n\n" .
    
$email_message "\n\n";
    
    
$file fopen($fileatt,'rb');
    
$data fread($file,filesize($fileatt));
    
fclose($file);
    
    
    
$data chunk_split(base64_encode($data));
    
    
$email_message .= "--{$mime_boundary}\n" .
    
"Content-Type: {$fileatt_type};\n" .
    
" name=\"{$fileatt_name}\"\n" .
    
//"Content-Disposition: attachment;\n" .
    //" filename=\"{$fileatt_name}\"\n" .
    
"Content-Transfer-Encoding: base64\n\n" .
    
$data "\n\n" .
    
"--{$mime_boundary}\n";
    unset(
$data);
    unset(
$file);
    unset(
$fileatt);
    unset(
$fileatt_type);
    unset(
$fileatt_name);
    
    
$ok = @mail($email_to$mailSubj$email_message$headers); 
pinkshiro is offline   Reply With Quote
Old 07-23-2008, 12:30 AM   PM User | #2
rafiki
Senior Coder

 
rafiki's Avatar
 
Join Date: Aug 2006
Location: Floating around somewhere...
Posts: 2,034
Thanks: 18
Thanked 42 Times in 42 Posts
rafiki will become famous soon enough
Maybe it's just their spam filter, ask them to add your domain to the "allowed list".
__________________
Get Firefox Now
rafiki is offline   Reply With Quote
Old 07-23-2008, 12:34 AM   PM User | #3
pinkshiro
New Coder

 
Join Date: Mar 2005
Posts: 85
Thanks: 3
Thanked 0 Times in 0 Posts
pinkshiro is an unknown quantity at this point
Yeah, tried that

This is the response I got...

Quote:
This is not something I can tell Mail Marshal to ignore.

It is seeing this as a fundamental mail structure fault rather than bad content.
Which leads me to believe my headers are screwed.
pinkshiro is offline   Reply With Quote
Old 07-23-2008, 01:18 AM   PM User | #4
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,292
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
You could try using something like PHPMailer. I had issues with emails getting put in the user's spam box when I was using the normal mail() function. Then I tried PHPMailer which does give you the option to send a plain text and html version of the email and since then the emails haven't been marked as spam.
__________________
||||If you are getting paid to do a job, don't ask for help on it!||||
_Aerospace_Eng_ is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:21 PM.


Advertisement
Log in to turn off these ads.