We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

unnecessary wordwrap in html codeigniter email

Development and Programming

petattlebaum's avatar
petattlebaum
60 posts
13 years ago
petattlebaum's avatar petattlebaum

I have a weird one. Below is my code for an html email using codeigniter in php enabled template. Oh, I’m using EE 2.5.1. For some strange reason that I can’t seem to figure out, line breaks are inserted into the text of my email on my mobile android device. I have the email set as html but the default mail app reads the emails in plain text format.

In thecode below, the text appears in the email this way: Print out and mail this form along with $15 for each compact disc; shipping is included. No cash accepted. Please make your check made payable to My Biz.

The text should look like this, with the wordwrap happening based on the width of the mobile devices screen.

Print out and mail this form along with $15 for each compact disc; shipping is included. No cash accepted. Please make your check made payable to My Biz.

I changed the words where it appears the line break is occuring (shipping and payable to (after to)) and the line break still occurs. So I think there’s an over-riding word wrap set at 75 characters. Is there any way I can over-ride that limit in the email? I have wordwrap set to false and it still doesn’t help.

Thanks! Peter T

$email_subject = "Order a CD Confirmation";
 $from = "[email protected]";
 $name = "My Biz";
 $reply_to = "$email";
 
 $email_msg = "<html>\r\n";           
 $email_msg .= "<head><meta charset=\"utf-8\"></head>\r\n";             
 $email_msg .= "<body>\r\n";         
 $email_msg .= "<style type=\"text/css\"><!--td {font-family: Georgia, \"Times New Roman\", Times, serif; font-size:12px;}--></style>\r\n";
 $email_msg = "<table border=\"0\" cellpadding=\"5\" cellspacing=\"0\" width=\"600\">\r\n";      
 $email_msg .= "<tr>\r\n";
 $email_msg .= "<td>\r\n";
 $email_msg .= "<span>Order A CD from My Biz</span>\r\n";
 $email_msg .= "</td>\r\n";
 $email_msg .= "</tr>\r\n";
 $email_msg .= "</table>\r\n";
 
 $email_msg .= "<table border=\"0\" cellpadding=\"5\" cellspacing=\"0\" width=\"600\">\r\n";                    
 $email_msg .= "<tr>\r\n";                
 $email_msg .= "<td colspan=\"2\" valign=\"top\">\r\n";
 $email_msg .= "</td>\r\n";             
 $email_msg .= "</tr>\r\n";
 $email_msg .= "<tr>\r\n";                
 $email_msg .= "<td colspan=\"2\" valign=\"top\">\r\n";
 $email_msg .= "Dear $firstName $lastName,\r\n \r\n"; 
 $email_msg .= "<strong>Thank you!</strong>\r\n \r\n";
 
 if ($payType == "CreditCard")
 {
  $email_msg .= "Call My Biz to use a credit card at (617) 555-1234 or print and mail this form, with your information included below, along with $15 for each compact disc; shipping included.
"."\r\n";
 }
 if ($payType == "Check")
 {
  $email_msg .= "Print out and mail this form along with $15 for each compact disc; shipping is included. No cash accepted. Please make your check made payable to My Biz."."\r\n\r\n";
  $email_msg .= "Send to:"."\r\n\r\n";
  $email_msg .= "My Biz"."\r\n";
  $email_msg .= "My Town, MA 99009"."\r\n";
 }
 $email_msg .= "</td></tr>\r\n"; 
 $email_msg .= "<tr><td width=\"200\">Program Number(s): </td><td width=\"400\">".$programNum."</td></tr>\r\n";
 $email_msg .= "<tr><td width=\"200\">Address: </td><td width=\"400\">".$address."</td></tr>\r\n";
 $email_msg .= "<tr><td width=\"200\">City: </td><td width=\"400\">".$city."</td></tr>\r\n";
 $email_msg .= "<tr><td width=\"200\">State: </td><td width=\"400\">".$state."</td></tr>\r\n";
 $email_msg .= "<tr><td width=\"200\">Postal Code: </td><td width=\"400\">".$zip."</td></tr>\r\n";
 $email_msg .= "<tr><td width=\"200\">Phone: </td><td width=\"400\">".$phone."</td></tr>\r\n";
 $email_msg .= "<tr><td width=\"200\">Email: </td><td width=\"400\">".$email."</td></tr>\r\n";
 $email_msg .= "<tr><td width=\"200\">Payment Type: </td><td width=\"400\">".$payType."</td></tr>\r\n";
  if ($payType == "CreditCard")
  { 
    $email_msg .= "<tr><td width=\"200\">Credit Card: </td><td width=\"400\">".$ccard."</td></tr>\r\n";
    $email_msg .= "<tr><td width=\"200\">Credit Card Number: </td><td width=\"400\">_____________________"."</td></tr>\r\n";
    
  } 
 $email_msg .= "</table>\r\n";               
 $email_msg .= "</body>\r\n";                       
 $email_msg .= "</html>\r\n";

 $this->EE->email->initialize();
 $this->EE->email->set_newline("\r\n");
 $this->EE->email->validate = true;
 $this->EE->email->wordwrap = false;
 $this->EE->email->mailtype = 'html';
 $this->EE->email->from($from, $name);
 $this->EE->email->reply_to($reply_to);
 $this->EE->email->to($email);
 $this->EE->email->subject($email_subject);
 $this->EE->email->message($email_msg);
 
 $this->EE->email->Send();
       
petattlebaum's avatar
petattlebaum
60 posts
13 years ago
petattlebaum's avatar petattlebaum

Darn, I just tried the fix from this post. But no luck. I’m still getting the weird line breaks in the text email.

Any ideas?

       
Jeremy -Ariba-'s avatar
Jeremy -Ariba-
6 posts
13 years ago
Jeremy -Ariba-'s avatar Jeremy -Ariba-

So are you now passing a text version when you call message()?

I recently had some issues with the email libraries and found that the body uses “quoted-printable” as the value for the ‘Content-Transfer-Encoding’ header for the HTML message when setting ‘mailtype’ to “html”. (You can see a call to _prep_quoted_printable() in the ‘html’ and ‘html-attach’ cases in _build_message().)

I believe quoted-printable encoding requires lines to be less than 76 characters, and EE/CI don’t allow you to change the encoding for the HTML portion of an MIME message. However, if you pass a text version, it should use the value of the $_encoding property (“8bit” by default).

       
petattlebaum's avatar
petattlebaum
60 posts
13 years ago
petattlebaum's avatar petattlebaum

Thanks for the find Jeremy. There definitely is some html setting that maxes the line at 76 characters. I’ve reverted back to text and its working fine.

       
brayantangler's avatar
brayantangler
1 posts
13 years ago
brayantangler's avatar brayantangler

The writing should look like this, with the wordwrap occurring based on the size of the mobile phones screen.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.