Ask not what osTicket community can do for you - ask what you can do for osTicket community

Go Back   osTicket Forums > osTicket 1.6.x > Mods and Customizations

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-05-2011, 05:56 PM
bkonia bkonia is offline
Junior Member
 
Join Date: Jul 2011
Posts: 9
Default [mod] HTML Email Templates

This mod adds a field called HTML Email Template to the Preferences screen. In this field, you can enter an HTML template that will be used for every outgoing email. Insert a %message placeholder where you want the text of the outgoing message to be inserted into the template. If the script finds the %message placeholder in this field, it will automatically create an HTML MIME part in every outgoing email, in addition to the existing text part.

The mod required changes to:

* class.email.php
* class.config.php
* preferences.inc.php

The modified versions of those files are attached. This will work as a drop-in replacement for the original files with version 1.6ST. Additionally, you will have to add a new field, "html_email_template", in the ost_config database table. The field type should be "text". All the changes are commented with my initials, BSK.

This mod also fixes a bug in class.config.php that was causing the "Allow Spoof" setting to become disabled every time the Preferences screen was saved, regardless of whether the checkbox was enabled or disabled. This is completely unrelated to HTML templates, but since it fixes a fairly nasty bug, I figured I may as well include it.
Attached Files
File Type: zip html_email_templates.zip (13.9 KB, 1247 views)

Last edited by bkonia; 08-05-2011 at 06:00 PM.
Reply With Quote
  #2  
Old 08-08-2011, 07:37 PM
mig2000 mig2000 is offline
Member
 
Join Date: Apr 2009
Posts: 60
Default

This MOD is only for the HTML Templates or it actually add the capability for OS Ticket to send Email in HTML?
Reply With Quote
  #3  
Old 08-08-2011, 07:57 PM
bkonia bkonia is offline
Junior Member
 
Join Date: Jul 2011
Posts: 9
Default

Quote:
Originally Posted by mig2000 View Post
This MOD is only for the HTML Templates or it actually add the capability for OS Ticket to send Email in HTML?
Not sure I understand your question. With this mod, osTicket will send all emails with both a plain text part and an HTML part. The mod creates the HTML part by wrapping an HTML template that you define around your plain text message that you would type in a support ticket, etc...

If you're asking whether you can use HTML within the actual message text, currently the answer would be no, because the HTML you enter would be sent in the plain text part of the email, which would make it unreadable for the 0.1% of people who still use plain text email programs.

On the other hand, it's pretty easy to update the mod to support HTML within the message text. On line 171 of my modified class.email.php, change:

$mime->setTXTBody($body);

to

$mime->setTXTBody(strip_tags($body));

Now, your HTML part will be sent as HTML and your text part will be stripped of all the HTML tags, so it will be sent as plain text.
Reply With Quote
  #4  
Old 08-10-2011, 07:48 PM
blazeman blazeman is offline
Junior Member
 
Join Date: Jun 2009
Posts: 2
Default

This worked great. Thanks for this mod!
Reply With Quote
  #5  
Old 10-03-2011, 01:14 PM
guiloc4 guiloc4 is offline
Junior Member
 
Join Date: Sep 2011
Posts: 3
Default

i get an error response that ends with:



Unknown column 'html_email_template' in 'field list'
Reply With Quote
  #6  
Old 10-03-2011, 01:31 PM
bkonia bkonia is offline
Junior Member
 
Join Date: Jul 2011
Posts: 9
Default

Quote:
Originally Posted by guiloc4 View Post
i get an error response that ends with:

Unknown column 'html_email_template' in 'field list'
That's correct. As I stated in my original post:

Additionally, you will have to add a new field, "html_email_template", in the ost_config database table. The field type should be "text".
Reply With Quote
  #7  
Old 10-19-2011, 12:09 PM
Paolo Poma Paolo Poma is offline
Junior Member
 
Join Date: Jun 2011
Posts: 8
Default

This MOD also allow to receive mail in html with image ?
i have a problem when the client open a ticket via e-mail and attach an immage (screen shot) in the test to explain his problem.
In this case in the ticket the image is lost.

thanks
Reply With Quote
  #8  
Old 10-19-2011, 12:40 PM
bkonia bkonia is offline
Junior Member
 
Join Date: Jul 2011
Posts: 9
Default

Quote:
Originally Posted by Paolo Poma View Post
This MOD also allow to receive mail in html with image ?
i have a problem when the client open a ticket via e-mail and attach an immage (screen shot) in the test to explain his problem.
In this case in the ticket the image is lost.

thanks
Sorry, but this mod has nothing to do with receiving emails. It affects sending only.
Reply With Quote
  #9  
Old 10-20-2011, 08:24 AM
krott krott is offline
Junior Member
 
Join Date: Oct 2011
Posts: 1
Default Help

How can I add new field?
What type command in mysql?
Reply With Quote
  #10  
Old 10-22-2011, 01:53 AM
AlphaDesignsGroup AlphaDesignsGroup is offline
Junior Member
 
Join Date: Oct 2011
Location: Wichita Falls, TX
Posts: 2
Default Most Excellent ;)

Excellent piece of code. Thank You very much. I think we can all agree that the original format was a bit plain without any formatting. Your instructions were well worded and worked perfect right out of the box. Fortunatly, for me, the three files you .zipped we some of the few that I had not already made other changes to... but...

There is always one of those in there... And this is not a bad thing, just a matter of conveneince for the person receiving the mail. I know the variables used in the orignal templates can not be used in the HTML box. The thing is, the link back to the support system to check/update your ticket info "was" an html link that could just be clicked on in the email. With the HTML format around it, it is no longer a link, but just text. This software is too new for me to figure it out, so I was wondering if anyone had found a way around that so clickable links could be put into the original templates, or code to find and convert links to a clickable link before it is sent. Thanks Bkonia !!!
Reply With Quote


Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:29 PM.