Jump to content

Recommended Posts

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 by mac_gyver
removed email address
Link to comment
https://forums.phpfreaks.com/topic/288784-php-mail-mime/
Share on other sites

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 

Link to comment
https://forums.phpfreaks.com/topic/288784-php-mail-mime/#findComment-1480907
Share on other sites

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;
Link to comment
https://forums.phpfreaks.com/topic/288784-php-mail-mime/#findComment-1480911
Share on other sites

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 

Link to comment
https://forums.phpfreaks.com/topic/288784-php-mail-mime/#findComment-1480916
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.