added html email support

- cleaner code in replaceTags function
- minor changes