Note that there are some explanatory texts on larger screens.

plurals
  1. POEncoding problem in From email and name when sending email in PHP?
    text
    copied!<p><strong>What could be causing this encoding problem? Am I encoding the header information correctly or could this be caused somewhere else?</strong></p> <p>I found a similar problem here: <a href="https://stackoverflow.com/questions/4389676/php-email-header-subject-encoding-problem">Email from PHP has broken Subject header encoding</a> but from what I'm reading I think I'm doing this right.</p> <p>Basically sometimes our clients send emails written in french. It works but every once in a while we get some encoding issues and I'm wondering if I did the encoding wrong (I can't figure out).</p> <pre><code>$from = '=?UTF-8?B?'.base64_encode($email['from_name']).'?= &lt;'.$email['from_email'].'&gt;'; $to = '=?UTF-8?B?'.base64_encode($email['to_name']).'?= &lt;'.$email['to_email'].'&gt;'; $get_param = array( 'Content-Type' =&gt; 'text/plain;charset=utf-8', 'Content-Transfer-Encoding' =&gt; '8bit'); </code></pre> <p>The code above is how I encode my header information and below is the sending:</p> <pre><code>$msg = $message_mime-&gt;get($get_param); $headers = array ( 'From' =&gt; $from, 'To' =&gt; $to, 'Reply-To' =&gt; $from, 'Subject' =&gt; utf8_decode($subject)); $headers = $message_mime-&gt;headers($headers); $smtp = Mail::factory('smtp', array ('host' =&gt; $smtp_settings['host'], 'auth' =&gt; true, 'username' =&gt; $smtp_settings['username'], 'password' =&gt; $smtp_settings['password'])); $mail = $smtp-&gt;send($to, $headers, $msg); </code></pre> <p>The problem is that the email they received was from:</p> <pre><code>Clientnamé de l'Ontario[=?UTF-8B?QXNzZW1ib(...)=?=] </code></pre> <p>Thanks for any help :)</p> <p>Edit: The client's name basically uses the same characters as above. What I mean is that the email was supposed to be from "Clientnamé de l'Ontario"</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload