I made a letter using HTML tags, such as <strong> , <a> , <h1> well, etc. generally.

But the problem is that the letters come "as is", i.e. tags are processed as text. Sent from GMail, Yandex, and using a PHP script.

How to typeset letters?

    4 answers 4

    Be sure to send an HTML header.

     $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=utf-8" . "\r\n"; $headers .= 'From: <from@example.com>' . "\r\n"; mail($to,$subject,$message,$headers); 

      All that is written is good, but far from the layout)

      To typeset letters, you need to remember the layout of '95, and zayuzat everything that was in it.

      1. All tags for 95 year starting from font, ending table
      2. All table layout
      3. It is better to use dock type HTML 3.2
      4. All inline styles - individual cc files or style tags MUST NOT BE
      5. And a bunch of small things that either look in Google, or learn from someone by example.

      Have a nice layout!

      • Thanks for the advice, but the problem is not solved? How to send an HTML email to someone through my mailer, leaving tags with tags, not text? - inferusvv
      • You also wrote above, you must specify the headers when sending:] - nolka
       function send_mime_mail($name_from, // имя отправителя $email_from, // email отправителя $email_to, // email получателя $data_charset, // кодировка переданных данных $send_charset, // кодировка письма $subject, // тема письма $body // текст письма ) { $to = $email_to; $subject = mime_header_encode($subject, $data_charset, $send_charset); $from = mime_header_encode($name_from, $data_charset, $send_charset).' <' . $email_from . '>'; if($data_charset != $send_charset) { $body = iconv($data_charset, $send_charset, $body); } $headers ="Content-type: text/html; charset=\"".$send_charset."\"\n"; $headers .="From: $from\n"; $headers.="Mime-Version: 1.0\n"; return mail($to, $subject, $body, $headers); } function mime_header_encode($str, $data_charset, $send_charset) { if($data_charset != $send_charset) { $str = iconv($data_charset, $send_charset, $str); } return '=?' . $send_charset . '?B?' . base64_encode($str) . '?='; } 
      • OK thanks. And if I want a friend to send a letter? Those. not using PHP, but from GMail - inferusvv
      • I think when using GMail for available text formatting via the web, the letter will already be sent to html, but here's how to use your formatting for you ... Then you can use any email program, in the settings you set it up that the letter is html and you are already creating it - YGOR -CHAMIN

      Use phpmailer from worx there everything is simple: create an instance of the class, stuffed the data about the topic, the sender and the recipient, set the title and text of the letter and sent it.