Author Topic: html tags in mails  (Read 6925 times)

0 Members and 1 Guest are viewing this topic.

Offline okram

  • Newbie
  • *
  • Posts: 32
    • View Profile
html tags in mails
« on: May 28, 2005, 02:45:26 AM »
hi i have seen all messages sent by 4images are in plain text. I want to use html tags in my messages, so i can include images and color in them... but i modified the postcard_message.html file in the lang folder and put in there some html tags, but the message is always only in text...

is there a mod ow a way to do it?

thanks

Offline boatman9999

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
Re: html tags in mails
« Reply #1 on: May 30, 2005, 01:12:12 PM »
Have you added the correct headers to the email message?

If not...

Go to includes/email.php

Find:

Code: [Select]
function create_header() {
    global $config;
    $header = "";
    if (empty($this->from)) {
      $header .= sprintf("Return-Path: %s\r\n", $config['site_email']);
      $header .= sprintf("From: %s\r\n", $config['site_email']);
    }
    else {
      $header .= $this->from;
    }
    //$header .= sprintf("Reply-to: %s\r\n", $config['site_email']);
    //$header .= sprintf("To: %s\r\n", $this->to);
    if (!empty($this->bcc) && !$this->use_smtp) {
      $bcc_list = "";
      foreach ($this->bcc as $key => $val) {
        $bcc_list .= (($bcc_list != "") ? ", " : "").$val;
      }
      $header .= sprintf("Bcc: %s\r\n", $bcc_list);
    }
    $header .= sprintf("Subject: %s\r\n", $this->subject);
    $header .= "Date: " . date("r") ."\r\n";
       
    return $header;
  }

Replace with:

Code: [Select]
function create_header() {
    global $config;
    $header = "";
    if (empty($this->from)) {
      $header .= sprintf("Return-Path: %s\r\n", $config['site_email']);
      $header .= sprintf("From: %s\r\n", $config['site_email']);
    }
    else {
      $header .= $this->from;
    }
    //$header .= sprintf("Reply-to: %s\r\n", $config['site_email']);
    //$header .= sprintf("To: %s\r\n", $this->to);
    if (!empty($this->bcc) && !$this->use_smtp) {
      $bcc_list = "";
      foreach ($this->bcc as $key => $val) {
        $bcc_list .= (($bcc_list != "") ? ", " : "").$val;
      }
      $header .= sprintf("Bcc: %s\r\n", $bcc_list);
    }
    $header .= sprintf("Subject: %s\r\n", $this->subject);
    $header .= "Date: " . date("r") ."\r\n";
    $header .= "MIME-Version: 1.0\r\n";
    $header .= "Content-Type: text/html; charset=windows-1252\r\n";
   
    return $header;
  }

which adds the headers
Code: [Select]
$headers.= "MIME-Version: 1.0\r\n";
$headers.= "Content-Type: text/html; charset=windows-1252\r\n";
to the email to tell the receiving email client that the message is HTML not plain text.

Be warned however that some email clients are set up to reject HTML messages and only accept Plain Text. A more sophisticated approach would be to send a two part message, first part being Plain Text, the second HTML which gives the best of both worlds.

This would take much more scripting however and would be worthy of a [MOD] in it's own right.


Offline brice626

  • Pre-Newbie
  • Posts: 7
    • View Profile
Re: html tags in mails
« Reply #2 on: June 08, 2005, 11:20:00 PM »
Found this incredibly helpful! The postcard email links were getting truncated by lots of email programs and thus people would have to copy and paste each part into their browser rather than clicking just once :)

Thanks!