Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

Updated for 1.7 - HTML Email Template

edited October 2013 in Mods and Customizations
Original Author - bkonia - http://osticket.com/forums/showthread.php?t=6393


I think I've got this to work in 1.7

Should just have to copy and paste the Updated Mod & Create the Html_email_Template DB entry as described below.All the changes are still commented with the original authors initials, BSK.

Login to PHPmyadmin > Select osTicket DB.

Run SQL command:
ALTER TABLE `ost_config` ADD `html_email_template` TEXT NULL DEFAULT NULL


include/class.config.php - Add @ ~ line 548
    
function getHtmlEmailTemplate(){ //BSK Retrieve HTML email template
return $this->config['html_email_template'];
}


Then Add the Following around Line 733

.',html_email_template='.db_input($vars['html_email_template']) // BSK Update HTML email template


include/class.email.php
Add after "//do some cleanup"

$htmlbody = str_replace('%message', str_replace(\"\n\", '<br />', $body), $cfg->getHtmlEmailTemplate());


Then Add the following after " $mime->setHTMLBody($htmlbody); "

if (strpos($cfg->getHtmlEmailTemplate(), '%message') !== false) //BSK If %message is found in the HTML email template, create HTML body MIME part
$mime->setHTMLBody($htmlbody);


include/staff/settings-emails.inc.php

After Line 104 Add...

</tr>
<tr><th>HTML Email Template:</th><?php //BSK HTML email template ?>
<td><textarea rows=\"15\" name=\"html_email_template\" style=\"width:600px;\"><?=$config['html_email_template']?></textarea><br><i>Will be used for all outgoing emails.<br />Insert %message where you want the message text to be replaced in the template.</i></td>
</tr>



After you impliment the above mod - Open class.ticket.php and comment out the following lines of code: ( x5 total )

//if($cfg->stripQuotedReply() && ($tag=$cfg->getReplySeparator()))
// $msg['body'] =\"\n$tag\n\n\".$msg['body'];


This will Make sure that the ReplySeparator does not get included twice on Replies.


~Cheers :D

UPDATE:
It turns out that using this MOD breaks being able to send attachments via the in ticket e-mail reply system. I assume this is because I inadvertently used the 1.6 version of class.email.php. As far as I noticed - this is the only thing that breaks. If someone figures out how to translate this document to 1.7 I would be grateful.

--------------------------------------------------------------------------------------------------------------------------

Check out My 1.7 Setup & MOD Guide

Comments

  • Error

    Hello,

    I tried to install the HTML MOD, but when I go to the mails settongs page that I agree, I get the following message
    Unable to update settings - Correct errors below and try again

    I'm not sure you have done all the steps correctly!

    Thank you for your help.
  • Does this also include the feature for the screendump?

    http://osticket.com/forums/showthread.php?t=6393&page=2
  • Syldo
    Please see my response to your question below.

    http://osticket.com/forums/showthread.php?t=6393&page=7


    adidasrta
    It may differ depending on your Mail Server. In our Exchange 2010 enviornment, All I had to do was add .png as an accepted file for incoming Mail. ( Admin Panel )

    This will save the screenshot as an attachment. As to the code changes you referenced, No I did not include that in my Update. I think most of it was added in 1.7 if i'm not mistaken....


    Update:
    Just Tested on a fresh osTicket install, Everything worked seamlessly. Can you post a screenshot of the actual error you are getting?
  • Can anyone else report back if this has worked for them or not? I think Syldos' issues are an isolated incident.
  • I don't know if it can help someone, but here's the email I receive automatically ...
    Mail error:

    [UPDATE Osticket_config SET updated=NOW() ,default_email_id=1,alert_email_id='0',default_smtp_id='0',admin_email='aurelie@gmail.com',enable_auto_cron=1,enable_mail_polling=1,strip_quoted_reply=1,reply_separator='-- NE RIEN ECRIRE SOUS CETTE LIGNE --',html_email_template='rnrnrn rn rn td, tr {border: 0}rn .ReadMsgBody {width: 100%;}rn .ExternalClass {width: 100%;}rn v\:* {display:inline-block;}rn rn rn
    rn rn rn rn rn rn rn rn rn rn rn
    rn

    td style= (my reply seperator - Used to truncate html sig files)rn

    rn rn rn rn rn rn rn rn rn rn rnrn
    rn imagern
    rn
    rn
    rn

    rn

    rn

    %messagern


    rnrn

    rn

    My Company. - Service Desk  |  [email]Helpdesk@Whdlaw.com[/email]  |  +414-999-555rn

    rn
    rn
    rn

     rn

    rn rn
    rn' WHERE id=1]

    Unknown column 'html_email_template' in 'field list'
  • syldo;38850 said:
    Unknown column 'html_email_template' in 'field list'
    From the original mod for 1.6:

    Additionally, you will have to add a new field, "html_email_template", in the ost_config database table. The field type should be "text".

    I'm guessing you still need to add that new field for the 1.7 version.
  • Looks like it.
  • Ok, I solved my problem and HTML mode now works.
    I followed your advice and regaining all this is ultimately good ...

    Thank you very much for your help ...
  • I've got this working nicely, and want to add on the comment for others using this, that with it you can actually add html code into your templates themselves. I was for the longest time trying to figure out how to add in the use of variables into the html template, but instead I moved the HTML itself into the message templates. This has allowed me to build better custom templates per type of email being sent.

    It should be mentioned that the remove slashes section of class.email.php can make more than basic code a pain to use. I've commented out line 166, and replaced line 167 with...
            $htmlbody = str_replace('%message', $message, $cfg->getHtmlEmailTemplate()); // BSK Create HTML body from HTML template and text body 
  • in this mod attachement is not working properly, can any one help me in this issue???
  • Please help us help you by actually supplying some information about the problem that you are experiencing. Please clearly describe the problem that you are having and give us more information about your setup. You should also look at your php error logs.
  • edited October 2013
    got error:

    Fatal error: Call to a member function getHtmlEmailTemplate() on a non-object in /usr/local/www/apache22/data/include/class.mailer.php on line 101

    :(:confused:
  • HTML in osTicket 1.7.1.4

    Dear Friend,

    Your help to apply the HTML mod on the current version.

    Best Regards.
    Qassam
  • Do you mind if you could guide me how to test a colorful email ?

    You included a test txt file in the zipped attachment

    where to paste it and how to check the results?
  • edited October 2013
    1.7.1?

    I can't seem to find some of the items you have listed within the specific files... did a lot change in 1.7.1? Will there be an updated version?
  • Unfortunately I'm no longer updating this MOD. Please treat the above code as reference only.
Sign In or Register to comment.