Community discussions

 
snowkiterdude
just joined
Topic Author
Posts: 4
Joined: Fri Jun 01, 2012 12:59 am

e-mail headers - Content-type: text/html

Fri Jun 01, 2012 1:20 am

I am customizing the usage report scripts in order to organize the data better and implement lowering a users speeds after their data cap is hit. To do this I need to be able to send e-mails with the header Content-type: text/html.

I have not been able to find any information on how to make this work.


The reliant code:
------------------------------------------------------------------------------------
:set text "$combinedtext <tr><td>$sitename:</td><td>$percentage% of $gigs GB</td><td>$megsdowncurrent MB</td><td>$megsupcurrent MB</td></tr>"
:set combinedtext "$text"

/tool e-mail send server="<my email server>" from="monitor@mycompany.com" to="$email" subject="Usage report on $date at $time" body="Site Usage Report
$text
Regards, monitor@mycompany.com"
:log info "Email sent to $email"
-----------------------------------------------------------------------------------
Here are the options I have under the Mikrotik send function. (RouterOS 5.5)
/tool e-mail send
body cc file from password port server subject tls to user
/tool e-mail edit
address from password port user value-name
/tool e-mail export
file hide-sensitive
/tool e-mail get
address from password port user value-name
/tool e-mail set
address from password port user
-----------------------------------------------------------------------------------
I usually do the same thing in php by:
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
and then use php's mail function and it works great.
-----------------------------------------------------------------------------------
We have to be able to add headers right?
A little help would be much appreciated.
Thanks in advance
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6283
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: e-mail headers - Content-type: text/html

Fri Jun 01, 2012 9:49 am

custom headers are not currently planned as a feature for e-mail tool.
 
snowkiterdude
just joined
Topic Author
Posts: 4
Joined: Fri Jun 01, 2012 12:59 am

Re: e-mail headers - Content-type: text/html

Fri Jun 01, 2012 6:32 pm

That's a bummer. Their are allot of e-mails these days that are no longer in plan text.

Does anyone know of any other ways that you can format e-mails without html/xml. My plan was to though all the data into an array that I could loop though to organize the data. Then through that data into a html table that could then be e-mailed and exported into excel for structured data and coloured graphs.

Or maybe I could have my web server add the header for me? Maybe a bash script that would add the text/html header on all e-mails coming from a certain source e-mail address.
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2411
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: e-mail headers - Content-type: text/html

Fri Jun 01, 2012 7:18 pm

If you really need to add custom headers, you could either:
1. Make an HTTP request to a PHP file using "/tool fetch". You can pass all needed variables into the URL. Once in PHP, you can add any additional headers you want, and send the mail from PHP.
2. Instead of sending the email to your email's real SMTP server, send it to another SMTP server, which you'd configure to forward the message to the real SMTP server, after adding additional headers to it. If you have control over the "real" SMTP server, you could directly configure it instead (just make sure to apply the rule only if the SMTP connection is from the router; you probably don't want to add those same headers to all emails).
PEAR2_Net_RouterOS(1.0.0b6) - My API client in PHP
(Rate my posts? If you want... no pressure...)
 
snowkiterdude
just joined
Topic Author
Posts: 4
Joined: Fri Jun 01, 2012 12:59 am

Re: e-mail headers - Content-type: text/html

Fri Jun 01, 2012 7:48 pm

If you really need to add custom headers, you could either:
1. Make an HTTP request to a PHP file using "/tool fetch". You can pass all needed variables into the URL. Once in PHP, you can add any additional headers you want, and send the mail from PHP.
2. Instead of sending the email to your email's real SMTP server, send it to another SMTP server, which you'd configure to forward the message to the real SMTP server, after adding additional headers to it. If you have control over the "real" SMTP server, you could directly configure it instead (just make sure to apply the rule only if the SMTP connection is from the router; you probably don't want to add those same headers to all emails).

Awesome thanks for the reply. I should be able to do everything I need in PHP :-).
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6283
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: e-mail headers - Content-type: text/html

Mon Jun 04, 2012 4:02 pm

or, just use monitoring software that gathers data, sends notifications and draws beautiful graphs. Why reinvent the wheel when working solutions are already available.
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2411
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: e-mail headers - Content-type: text/html

Mon Jun 04, 2012 4:18 pm

or, just use monitoring software that gathers data, sends notifications and draws beautiful graphs. Why reinvent the wheel when working solutions are already available.
Any "of the shelf" working solution you have in mind (I know at least 4 people that would be interested, myself included)?
PEAR2_Net_RouterOS(1.0.0b6) - My API client in PHP
(Rate my posts? If you want... no pressure...)

Who is online

Users browsing this forum: No registered users and 15 guests