AnsweredAssumed Answered

Bare Linefeeds in HTML email using BaseElements plugin

Question asked by User26869 on Mar 5, 2018
Latest reply on Mar 7, 2018 by steve_ssh

Dear community,

 

I have recently started to get bounces from html emails sent from Filemaker using the BaseElements plugin. The message is rejected by the Office 365 servers (outgoing).

The error from Office 365 is the following:

Your message contains invalid characters (bare line feed characters) which the email servers at krcs.co.uk don't support.

 

How to Fix It

It appears that your email program added invalid characters (bare line feed characters) into your message when you sent it. Try using a different email program to send your message. If the problem continues send this non-delivery report (NDR) message to your email admin for assistance.

The email is created by a script performed on the server. Its body, recipient, etc is sent to this script via JSON parameters.

Set Variable [ $path; Value:Get ( ScriptResult ) ]

Set Variable [ $JSON; Value:"{}" ]

Set Variable [ $JSON; Value:JSONSetElement ( $JSON ;
[ "email" ; $email ; 1 ] ; [ "subject" ; $subject ; 1 ] ;
[ "header" ; $header ; 1 ] ;
[ "customer" ; $customer ; 1 ] ;
[ "footer" ; $footer ; 1 ] ;
[ "customer_id" ; $id_customer ; 1 ] ;
[ "appointment_id" ; Appointment::id ; 1 ] ;
[ "attachment_path" ; $path ; 1 ]

)]

Set Variable [ $smtp; Value:JSONSetElement ( "" ;
["name"; $smtp_name; 1] ;
["email"; $smtp_email; 1] ;
["reply"; $smtp_reply; 1] ;

["outgoing"; $smtp_outgoing; 1] ;

["port"; $smtp_port; 1] ;

["username"; $smtp_username ; 1] ;

["password"; $smtp_password ; 1] )]

Set Variable [ $JSON; Value:JSONSetElement ( $JSON ; "SMTP" ; $smtp ; JSONObject) ]

Perform Script on Server [ “Send HTML Email On Server(JSON)”; Parameter: $JSON ]

[ Wait for completion ]

Then the script on the server gets this values and creates an email via BaseElements:

Set Variable [ $email; Value:JSONGetElement ( Get ( ScriptParameter ) ; "email" ) ]

Set Variable [ $subject; Value:JSONGetElement ( Get ( ScriptParameter ) ; "subject" ) ]

Set Variable [ $content; Value:Substitute ( JSONGetElement ( Get ( ScriptParameter ) ; "header" ) & JSONGetElement ( Get ( ScriptParameter ) ; "customer" ) & JSONGetElement ( Get ( ScriptParameter ) ; "footer" ) ; Char ( 13 ) ; Char ( 10 ) ) ] <-- Here I did the substitution suggested on BE_SMTP_Send – BaseElements Plugin Help Centre

Set Variable [ $id_customer; Value:JSONGetElement ( Get ( ScriptParameter ) ; "customer_id" ) ]
Set Variable [ $id_appointment; Value:JSONGetElement ( Get ( ScriptParameter ) ; "appointment_id" ) ]
#Substitute "/" to "\\" to make sure the slashes are the right ones for windows
Set Variable [ $path; Value:Substitute ( JSONGetElement ( Get ( ScriptParameter ) ; "attachment_path" ) ; "/" ; "\\" ) ]

 

Set Variable [ $smtp_outgoing; Value:JSONGetElement ( Get ( ScriptParameter ) ; "SMTP.outgoing" ) ]

Set Variable [ $smtp_port; Value:JSONGetElement ( Get ( ScriptParameter ) ; "SMTP.port" ) ]
Set Variable [ $smtp_username; Value:JSONGetElement ( Get ( ScriptParameter ) ; "SMTP.username" ) ]

Set Variable [ $smtp_password; Value:JSONGetElement ( Get ( ScriptParameter ) ; "SMTP.password" ) ]

Set Variable [ $smtp_email; Value:JSONGetElement ( Get ( ScriptParameter ) ; "SMTP.email" ) ]

Set Variable [ $smtp_reply; Value:JSONGetElement ( Get ( ScriptParameter ) ; "SMTP.reply" ) ]

 

Set Variable [ $smtp; Value:BE_SMTP_Server ( $smtp_outgoing ; $smtp_port ; $smtp_username ; $smtp_password ) ]
Set Variable [ $curl; Value:BE_Curl_Set_Option ( "BE_CURLOPT_FORCE_STARTTLS" ; True ) ]
Set Variable [ $send; Value:BE_SMTP_Send ( $smtp_email ; $email ; $subject ; "" ; "" ; "" ; $smtp_reply ; $content ; $path ) ]

I have also tried substituting Char(10) by Char(13), but I didn't work either.
I'd be grateful if any of you came across this issue and/or have an idea to fix it, because I'm quite at a loss.
Thank you very much!
Chloe

 

Outcomes