Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Mar 2005
    Thanked 0 Times in 0 Posts

    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));
    $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" .
    $ok = @mail($email_to$mailSubj$email_message$headers); 

  • #2
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Floating around somewhere...
    Thanked 42 Times in 42 Posts
    Maybe it's just their spam filter, ask them to add your domain to the "allowed list".

  • #3
    New Coder
    Join Date
    Mar 2005
    Thanked 0 Times in 0 Posts
    Yeah, tried that

    This is the response I got...

    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.

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    In a place far, far away...
    Thanked 1,043 Times in 1,019 Posts
    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!||||


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts