From 459c0ccdf5ec5ff71debdc8248e6531aed48eb73 Mon Sep 17 00:00:00 2001 From: gandy92 Date: Sat, 16 May 2015 18:23:19 +0000 Subject: [PATCH] 76_MSGMail: Add attribute mailtype as suggested by Roger (forum #37206) git-svn-id: https://svn.fhem.de/fhem/trunk@8587 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 2 ++ fhem/FHEM/76_MSGMail.pm | 20 +++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index d60b8e2a9..740058492 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,7 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - feature: 76_MSGMail: Add attribute mailtype as suggested by Roger + (forum #37206) - feature: 30_pilight_temp: reading battery state, attribut corrTemp to correct temperature - change: 73_km200: Wrong SwitchProgram time format fixed - feature: 73_km200: SwitchPrograms can be written/changed diff --git a/fhem/FHEM/76_MSGMail.pm b/fhem/FHEM/76_MSGMail.pm index 926ae2cba..57aed5e29 100644 --- a/fhem/FHEM/76_MSGMail.pm +++ b/fhem/FHEM/76_MSGMail.pm @@ -4,6 +4,7 @@ # # History: # +# 2015-05-15: Add attribute mailtype as suggested by Roger (forum #37206) # 2015-05-11: Improve error logging to assist problem solving # 2015-05-09: Assimilate mail related code from 75_MSG # 2015-05-06: Tidy up code for restructuring @@ -47,7 +48,7 @@ sub MSGMail_Initialize($) $hash->{SetFn} = "MSGMail_Set"; $hash->{DefFn} = "MSGMail_Define"; $hash->{UndefFn} = "MSGMail_Undef"; - $hash->{AttrList} = "loglevel:0,1,2,3,4,5,6 authfile smtphost smtpport subject from to cc CR:0,1"; + $hash->{AttrList} = "loglevel:0,1,2,3,4,5,6 authfile smtphost smtpport subject mailtype:plain,html from to cc CR:0,1"; my $name = "MSGMail"; @@ -97,6 +98,7 @@ sub MSGMail_Define($$) $attr{$name}{to} = $a[3]; $attr{$name}{smtphost} = $a[4]; $attr{$name}{authfile} = $a[5]; + $attr{$name}{mailtype} = "plain"; $attr{$name}{subject} = "FHEM "; $attr{$name}{CR} = "1"; @@ -203,6 +205,10 @@ sub MSGMail_Set($@) my $smtphost = AttrVal($name, "smtphost", ""); my $smtpport = AttrVal($name, "smtpport", "465"); # 465 is the default port my $cc = AttrVal($name, "cc", ""); # Carbon Copy + my $mtype = AttrVal($name, "mailtype", "plain"); + + my $mailtype = "text/plain"; + $mailtype= "text/$mtype" if ($mtype =~ m/^(plain|html)$/); return "No address specified, use attr $name from " if (!$from); @@ -235,7 +241,7 @@ sub MSGMail_Set($@) From => $from, To => $to, Subject => $subject, - Type => 'text/plain; charset=UTF-8', #'multipart/mixed', # was 'text/plain' + Type => "$mailtype; charset=UTF-8", #'multipart/mixed', # was 'text/plain' Data => $mess ); @@ -357,8 +363,8 @@ sub MSGMail_conn($)
    clear
    to flush the message buffer and set the line counter to 0. All the lines of data are deleted and the buffer is flushed.
-
    list
    to list the message buffer.

-
    send
    to send the message buffer.

+
    list
    to list the message buffer.
+
    send
    to send the message buffer.

Examples:
    @@ -409,7 +415,11 @@ sub MSGMail_conn($) of the file. FHEM must have access to this file to read the userid and password.
    -
  • CR
    +
  • mailtype plain|html
    + Use this attribute to select the contenttype to text/plain or text/html. + If text/html is selected, valid html code must be provided as content. No checks are applied! + Per default this attribute is 'plain'
  • +
  • CR
    set the option to write a carriage return at the end of the line. CR could be set to 0 or 1, 1 enables this feature. Per default this attribute is enabled