I am sending mails to users about products, using the SMTP Authentication Support and Mime Mail modules. I set UTF8 as charset in the mail header, but the header is changed from UTF8 to multipart on this line in the mail.inc file:

$message = $system->format($message);

It actually changes the Swedish characters to some strange characters. So that's the problem: I can't display them correctly.

Any suggestions to correctly display them?


Content-Type: multipart/alternative; means that there are parts that can have their own encoding set. If your mail sending modules decide they need multipart, mail should be formatted like that:

MIME-Version: 1.0
Content-Type: multipart/alternative; boundary=boundary

Content-Type: text/plain; charset=utf-8

This part uses UTF-8.
Content-Type: text/plain; charset=iso-8859-1

This part uses ISO 8859-1.

code sample source here

If you called everything the way module docs tells you to, and UTF-8 data is not in the UTF-8 part, then you just found a bug in one of your modules.

  • Can't say more without a full code. – Mołot Mar 3 '14 at 15:30
  • These are the headers that I use. <code> $headers = array( 'MIME-Version' => '1.0', 'Content-Type' => 'text/html; charset=UTF-8; format = flowed;', 'Content-Transfer-Encoding' => '8Bit', 'X-Mailer' => 'Drupal' ); foreach ($headers as $key => $value) { $message['headers'][$key] = $value; } </code> – rashidkhan Mar 3 '14 at 15:46
  • Given the information the question contains, this is a plausible answer, and hits the point. Setting multipart/alternative as content type doesn't conflict with setting the charset. That means that or a module contains a bug, or a module has not been correctly configured. – kiamlaluno Aug 10 '17 at 6:18

Hi you can also create this functionality using custom hooks.

function add_newsletter() {
 $news_query = db_insert('news_letter')
            'email_id' => $_POST['email'],
            'created' => REQUEST_TIME))
if($news_query) {
    echo '1';
}else {
    echo '0';

$to = "abc_example@gmail.com";
$subject  = 'Mail coming from Subscribe';
$message  = "Hi, please check the below email coming from User Subscribers. User Email Id is : ".$_POST['email'];
$headers  = 'From: '.$_POST['email'] . "\r\n" .
            'MIME-Version: 1.0' . "\r\n" .
            'Content-type: text/html; charset=utf-8';
mail($to, $subject, $message, $headers);
if(mail($to, $subject, $message, $headers))
    echo "Email sent successfully";
    echo "Email sending failed";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.