Community discussions

MikroTik App
 
klaus007
just joined
Topic Author
Posts: 19
Joined: Thu Aug 17, 2017 1:11 pm

Email probleme "invalid body"

Thu Jul 19, 2018 2:30 pm

Hello!

I´m using the script below to Forward SMS to email. If the SMS has only one row, everthing works like a charme. When the SMS has more then one row, the sendingprocedure fails and I get an error "invalid Body" ind log. Any Ideas?

:local EmailAddress "xxxx.yyyy@zzz.at";
:local smsPhone;
:local smsTimeStamp;
:local smsMessage;
:local smsContent;

# Get System Identity #
:local SystemID [/system identity get name];

:log info "SMS to Email script started";

# Set Receive Enabled, in case it was cleared by a router reboot #
/tool sms set receive-enabled=yes;

delay 1;

/tool sms set port=lte1

delay 1;

# loop through all the messages in the inbox #
:foreach i in=[/tool sms inbox find] do={

:set smsPhone [/tool sms inbox get $i phone];
:set smsTimeStamp [/tool sms inbox get $i timestamp];
:set smsMessage [/tool sms inbox get $i message];

:set smsContent "$SystemID \_SMS Received from: $smsPhone\_Date&Time: $smsTimeStamp \_Message: $smsMessage";

:log info $smsContent;

/tool e-mail send start-tls=yes subject="$SystemID GSM Modem SMS Received" to=$EmailAddress body="$smsContent";

# Now remove the SMS from the inbox #
/tool sms inbox remove $i;

delay 5;

}

:log info "SMS to Email script complete"


Kind regards
 
User avatar
32768
just joined
Posts: 23
Joined: Fri Mar 16, 2018 3:59 pm
Location: Switzerland
Contact:

Re: Email probleme "invalid body"

Sat Jul 21, 2018 11:48 pm

could it be that the problem has something to do with the \n or \r\n differences in linebreaks?
only a suggestion ;-)
 
klaus007
just joined
Topic Author
Posts: 19
Joined: Thu Aug 17, 2017 1:11 pm

Re: Email probleme "invalid body"

Sun Jul 22, 2018 11:18 am

Hello!

Yes, when the SMS has no linebreak, everything works. With a linebreak it fails. And some SMS I receive has some linebreaks.
So I´ve no idea what the problem is.
 
User avatar
32768
just joined
Posts: 23
Joined: Fri Mar 16, 2018 3:59 pm
Location: Switzerland
Contact:

Re: Email probleme "invalid body"

Sun Jul 22, 2018 11:30 pm

maybe I have mispronounced myself, I mean it might be related to the fact that there are different encodings for line breaks.
have you checked what encoding is used in sms?

unix world uses \n (chr 13) only, windows world is using \r\n (chr 10, chr 13)

Who is online

Users browsing this forum: Jonty and 17 guests