CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • HTML Receipt e-mails
Pages: [1]

Author Topic: HTML Receipt e-mails  (Read 1044 times)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
HTML Receipt e-mails
August 04, 2009, 07:25:10 pm
Hello,

I have discussed this briefly on the IRC with a very busy Lobo but moving it over here.

I got a quick win on sending out html e-mails by making the following changes:

1) Change Utils/Mail.php to send out html messages correctly if the $html_message variable is passed in (currently it almost works...)


        if ($html_message){
          $headers['Content-Type']              = 'multipart/mixed; charset=utf-8';
        }else{
            $headers['Content-Type']              = 'text/plain; charset=utf-8'; 
        }

2) Created a htmlReceiptMessage.tpl in
templates\CRM\Contribute\Form\Contribution

(ie. the same as the ReceiptMessage.tpl with a bit of formatting)

3) Edited CRM/Contribute/BAO/ContributionPage.php to pass through the $html_message

+ line 203
         $htmlMessage = $template->fetch( 'CRM/Contribute/Form/Contribution/htmlReceiptMessage.tpl' );

and added $htmlMessage further down.

            if ( $values['is_email_receipt'] ) {
                CRM_Utils_Mail::send( $receiptFrom,
                                      $displayName,
                                      $email,
                                      $subject,
                                      $message,
                                      CRM_Utils_Array::value( 'cc_receipt' , $values ),
                                      CRM_Utils_Array::value( 'bcc_receipt', $values ),
                                      NULL,
                                      $htmlMessage
                                      );

 
This makes a huge improvement to the look of the e-mails which go out. My instinct was to add something to check the recipient's preferred format into that mail.php so that wherever that function was called from it could do that checking and construct the e-mail as appropriate.

e.g

  $params  = array( 'contact_id' => $contactId );             
 $contact =& civicrm_contact_get( $params );     
$preferred_mail_format = $contact['preferred_mail_format']
if ($preferred_mail_format=="Both" then

etc

BUT, LOBO has pointed out that changing this won't change all the e-mail content to be properly formatted html. I was thinking it was maybe a necessary pre-requisite for that step, however, and one that would enable some easy wins.

Thoughts?

NB - I would note that the first tweak - ie..  step 1 is a bug fix rather than a change as it just makes the existing ability to send in $html_message as a variable actually work.
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: HTML Receipt e-mails
August 06, 2009, 01:15:43 am
Logged the first bit of this - the bit where the function doesn't work as it should

http://issues.civicrm.org/jira/browse/CRM-4868
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • HTML Receipt e-mails

This forum was archived on 2017-11-26.