Page 1 of 1

Email content not visible when recieved at yahoo.com

Posted: Wed Nov 29, 2006 9:53 am
by Megalepozy
Hi all,

I'm sending an email to a mailing list, the email contain html content and it's getting displayed perfectly at gmail, thunderbird and so on.... while at yahoo.com (not including their new beta mail client) and walla.co.il the content of the email is just empty.

I noticed that at yahoo.com & walla.co.il the subject of the email isn't displayed correctly with the hebrew letters, mabye it's a problem cause of the encoding?

I wrote the following code:

Code: Select all

$maillist_recipents  = array();
  $sender_e_mail      = "support@bazz.co.il";
  $sender_name	      = "Bazz.co.il";
  $subject 	            = "Bazz.co.il mailing list test";

  require("/include/Swift/Swift.php");
  require("/include/Swift/Swift/Connection/SMTP.php");
  require("/include/Swift/Swift/Plugin/AntiFlood.php");
	
  $connectionObject = new Swift_Connection_SMTP('localhost',25);
  $swift = new Swift($connectionObject);
  
  $swift->setCharset('WINDOWS-1255');

  if(!$swift->isConnected()) {
          return false;
  }

  //100 mails per batch with a 90 second pause between batches
  $swift->loadPlugin(new Swift_Plugin_AntiFlood(100, 90));

  // for non html compatible clients
  $swift->addPart("blah blah in hebrew");
  
  $body = $this->arrangeMaillistBody ($maillist_mail_id);
  
  $swift->addPart($body, 'text/html');
  
  // just retrieve an array of maillist recipents
  $maillist_recipents = $this->retrieveMaillistSubscribers($maillist_mail_id);

  //Make the script run until it's finished in the background
  set_time_limit(0); ignore_user_abort();

  echo "<b>".hebrev("blah blah in hebrew again")."</b><br /><br />";
  
  flush(); ob_flush();
   
  $swift->send($maillist_recipents, $sender_name.' <'.$sender_e_mail.'>', $subject, false, 'text/html', 'WINDOWS-1255');
 
  print ("The emails were sent successfully <br>");
  print("<pre>");
  print("</pre>");

  $swift->close();
Thanks a lot!
Yonatan

Posted: Wed Nov 29, 2006 10:16 am
by Chris Corbyn
With any of the web-page based e-mail providers you're lucky if a charset other than UTF-8 or ISO-8859-1 will display correctly. They need to do a bit of magic with the charset to allow it work with whatever charset they have their web page set to. Are you maybe able to use UTF-8?

Alsom try explicitly setting the encoding to 8bit in addPart:

Code: Select all

$swift->addPart("blah blah in hebrew", "tex/plain", "8bit");
 
  $body = $this->arrangeMaillistBody ($maillist_mail_id);
 
  $swift->addPart($body, 'text/html', "8bit");

8bit did improve the result

Posted: Wed Nov 29, 2006 1:25 pm
by Megalepozy
Hi again,

Well the 8bit did make the content appear (thanks d11wtq) but the charset doesn't appear right (need to change the encoding each time to view it properly).
I tried to play with it a little but sadly I wasn't able to receive any better results.
If anyone got a thought about it feel free to pop it up :)

Thanks again,
Yonatan

Posted: Wed Nov 29, 2006 3:04 pm
by Chris Corbyn
Are you still using WINDOWS-1255 ? Lowercase the text by the way ;) When you say you need to change the charset do you mean in the e-mail client or the web page or Swift itself?

Swift doesn't actually convert charsets or anything mostly because I'd have to depend upon PHP extensions being installed to do that so it just takes it as true that the charset is what you say it is. Is the file this text is coming from encoded in windows-1255 ? Are you able to send an email from Outlook or Thunderbird with windows-1255 text and have it display correctly in the web page?

We'll get this working :)

Posted: Thu Nov 30, 2006 6:00 am
by Megalepozy
Well I changed the encoding to iso-8859-8 at swift itself:

Code: Select all

$swift->setCharset('iso-8859-8'); 
$swift->send($maillist_recipents, $sender_name.' <'.$sender_e_mail.'>', $subject, false, 'text/html', 'iso-8859-8');
and at the page where the email content is being created:

Code: Select all

header("Content-Type: text/html; charset=iso-8859-8");
Now the content is visible and understandable also at walla.co.il so the only email client (which I know of) that make any problems is yahoo.com (not including their new beta mail service) which show the content but in gibberish, to display it correctly one has to change its browser encoding to iso-8859-8 or Hebrew (windows).

When tried to send an email from Thunderbird to yahoo.com & walla.co.il which included Hebrew text it was displayed perfectly at walla.co.il while yahoo.com (again only the older version) made the same problems so I think that yahoo.com just doesn't support it, actually I also guess that people with an account there are probably used to switch their encoding each time an Hebrew email is being sent to them so it's not such a big problem...

Thanks a lot again for your help!
Yonatan

Posted: Thu Nov 30, 2006 9:47 am
by Chris Corbyn
Seriously, the most portable solution for this would be to switch to UTF-8 everywhere :)

Posted: Thu Nov 30, 2006 10:34 am
by Megalepozy
Sadly that can't be done cause the site is extremely old (about 6-7 years) and it will be too expensive for the owners to migrate the site to UTF-8... and already I'm half volunteering here..... so...

Anyway thanks a lot for your help and of course Swift itself which is really a great library :)

May you get your mac mini shortly (added a little to the raise :)),
Yonatan

Posted: Tue Dec 19, 2006 3:35 pm
by benklinger
Yonatan - can you please email me? i have the same exact problem.

danykoren (((at))) gmail (((dot))) com

Posted: Tue Dec 19, 2006 3:54 pm
by Chris Corbyn
Are either of you using PHP5? I ask because if you wanted to I could give you instructions for trying the same operation with the version under development in subversion to see if that makes any difference.

Posted: Tue Dec 19, 2006 4:28 pm
by Megalepozy
Well for that problem I used the php4 version cause the site is quite old...
Anyway it's working fine now so I'm content :)

benklinger I'll email you now.

Cheers everyone, and again thanks for this great library!
Ben-Nes Yonatan