LeeAppleby Posted May 26, 2014 Share Posted May 26, 2014 (edited) hi all new to php and having a sturggle with email. I have a a form that when completed I wish to auto email the results to a new member simple enough . i also create a image with their unique name and member type and attach this to the email. I can attach the image and send an html email however I wish to send a plain text email along with this. here lies the problem. $to = $email ; $subject = 'some subject'; $bound_text = "010103689954"; $bound = "--".$bound_text."\r\n"; $bound_last = "--".$bound_text."--\r\n"; $headers = "From: <snip email removed>\r\n"; $headers .= "MIME-Version: 1.0\r\n" ."Content-Type: multipart/mixed; boundary=\"$bound_text\""; $message .= "If you can see this MIME than your client doesn't accept MIME types!\r\n" .$bound; /*HTML part of email*/ $message .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n"; $message .="Content-Transfer-Encoding: 7bit\r\n\r\n"; $message .='<html><b>html version</b></html>\r\n' .$bound; /*Plain Text part of email*/ $message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n"; $message .="Plain text version\r\n" .$bound; /*Attachment part of the email adds jpeg memebrship card*/ $file = file_get_contents("create_membership_card.php?forename=$Forename&surname=$Surname&membership=$Membership"); $message .= "Content-Type: image/jpg; name=\"YourMembershipCard.jpg\"\r\n" ."Content-Transfer-Encoding: base64\r\n" ."Content-disposition: attachment; file=\"YourMembershipCard.jpg\"\r\n" ."\r\n" .chunk_split(base64_encode($file)) .$bound_last; mail($to, $subject, $message, $headers) This will send email in html and attach image but I can not get it to also send the plain/test version. example page to enter email and see what is sent http://www.hexhamcanoeclub.co.uk/Hexham/index.php?page=Email Any help with this would be great thanks in advance hope I have provided enough information Lee ps. great place you have here Edited May 30, 2014 by mac_gyver removed email address Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted May 26, 2014 Share Posted May 26, 2014 What part of this script does't work to you? Because I made a test from my local server and works fine to me. Quote Link to comment Share on other sites More sharing options...
LeeAppleby Posted May 26, 2014 Author Share Posted May 26, 2014 Hi it sends the html header and the attachment but for me it does not send the text/plain element of the email so it is only sending Content-Type: text/html; and also the attachment and not Content-Type: text/plain version. I thought perhaps I had a problem with bound. thanks for testing It Jazzman1 Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted May 26, 2014 Share Posted May 26, 2014 Here is what I get: html version\r\n--010103689954 Content-Type: text/plain; charset="iso-8859-1" Plain text version and the attached photo. Is this correct? You need to change your code in the line 13 $message .= "If you can see this MIME than your client doesn't accept MIME types!\r\n" .$bound; // to $message = "If you can see this MIME than your client doesn't accept MIME types!\r\n" .$bound; Quote Link to comment Share on other sites More sharing options...
LeeAppleby Posted May 26, 2014 Author Share Posted May 26, 2014 I get this at the bottom of the email in oulook --010103689954 Content-Type: text/plain; charset="iso-8859-1" Plain text version showing up here and should not should only be included if not supported html and it should not really show this should only show if I could not get the html version. so im trying to include two versions html and plain/text . hope that makes sense my heads been going in circles for days now lol. thanks for taking the time to look and help Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted May 26, 2014 Share Posted May 26, 2014 Change the line 21 $message .='<html><b>html version</b></html> \r\n' // to $message .="<html><b>html version</b></html> \r\n" Quote Link to comment Share on other sites More sharing options...
LeeAppleby Posted May 26, 2014 Author Share Posted May 26, 2014 Yep your exactly right staring me right in the face . Thank you very much for taking the time to look and to reply with a solution. best regards Lee Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.