27747

Sending mail with PHP in forgein languages

Question:

I have a php mail script that works well except for one minor fact. In Outlook (all version), the email comes in gibrish. If the email is read through an internet browser (like Gmail.com), it's fine. Is it possible to have the email look good in Outlook as well? I tried emailing it as HTML, still to no avail.

I can post the full code if necessary, but it looks something like this:

these are the headers:

$email = $_REQUEST['email']; $headers = 'From: ' . $email . "\r\n" . 'Reply-To: ' . $email . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $headers .= "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-Type: Text/plain; charset=ISO-8859-8";

uses the mail() function:

mail ($to, $subject, $message, $headers);

I've tried to find ways to maybe encode incoming Outlook messages differently, but I (1) couldn't find a way to do so, and (2) would rather have it this way since it's supposed to go to a lot of people.

EDIT: After adding the line below, the message properly rendered both in browsers as well as Outlook. Hope this helps someone!

//convert to utf-8 $message = mb_convert_encoding( $message , 'ISO-8859-8' , 'utf-8' );

Thanks! Amit

Answer1:

Should be pretty easy, change charset=ISO-8859-8 to charset=UTF-8

Also be sure the creating page is encoded as UTF-8 and that if a database is used, the table ( or whole db ) is in UTF-8 unicode general

With UTF-8 you can write the characters as they appear, don't use entities.

Recommend

  • MongoDB Exception: Server reports wire version 0, but version of libmongoc requires at least 3
  • How do you use authentication with gmail for a PHP contact form?
  • Php mail function error, mail sent from wrong address
  • Hide '”' from inspect element
  • mod_rewrite not passing querystring
  • How to add extra text to the tag in Joomla
  • PHP to connect to Hotmail to send email?
  • Retrieving images from GridFS using django-tastypie-mongoengine
  • ClickOnce is not working in Internet Explorer 9
  • Symfony2 Service Container - does get() return objects by reference or copy?
  • How to configure Joomla 1.7 SMTP email with a google apps email address
  • onFocus and onBlur
  • Using nodejs server with request package and function pipe()?
  • HTML 5 video (ogv) and MIME types
  • PHP - sending email with attachment does not show message content
  • How to reply a tweet using the Twitter gem?
  • get latest text entry of GROUP BY statement
  • how to convert open xml representation of word document into RTF format using c#.net 4.0?
  • HTML code to upload images
  • PHP: Calling a private method from within a class dying badly
  • print() is showing quotation marks in results
  • Content-Length header not returned from Pylons response
  • Make VS2015 use angular-cli ng at build time in a .NET project
  • Android fill_parent issue
  • Get object from AWS S3 as a stream
  • How to apply VCL Styles to DLL-based forms in Inno Setup?
  • Upload files with Ajax and Jquery
  • Do I've to free mysql result after storing it?
  • Warning: Can't call setState (or forceUpdate) on an unmounted component
  • A cron job substitute?
  • json Serialization in asp
  • Acquiring multiple attributes from .xml file in c#
  • Free memory of cv::Mat loaded using FileStorage API
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Memory offsets in inline assembly
  • Turn off referential integrity in Derby? is it possible?
  • How can I remove ASP.NET Designer.cs files?
  • Can't mass-assign protected attributes when import data from csv file
  • java string with new operator and a literal
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize