diff --git a/backend/files/misc/workflows/actions/send-email-from.hl b/backend/files/misc/workflows/actions/send-email-from.hl deleted file mode 100644 index 727219c192..0000000000 --- a/backend/files/misc/workflows/actions/send-email-from.hl +++ /dev/null @@ -1,70 +0,0 @@ - -/* - * Sends an email to the specified [name]/[email] recipient, - * with the specified [subject] and [body], using the specified [from] and [from-email] - * as the sender. - */ -.arguments - name - type:string - mandatory:bool:true - email - type:email - mandatory:bool:true - from - type:string - mandatory:bool:true - from-email - type:email - mandatory:bool:true - subject - type:string - mandatory:bool:true - body - type:textarea - mandatory:bool:true - html - type:bool - mandatory:bool:false -.icon:email - -// Sanity checking invocation. -validators.mandatory:x:@.arguments/*/name -validators.mandatory:x:@.arguments/*/email -validators.email:x:@.arguments/*/email -validators.mandatory:x:@.arguments/*/from -validators.mandatory:x:@.arguments/*/from-email -validators.email:x:@.arguments/*/from-email -validators.mandatory:x:@.arguments/*/subject -validators.mandatory:x:@.arguments/*/body - -// Applying defaults. -validators.default:x:@.arguments - html:bool:false - -// Making sure we send email as HTML if we should. -if - get-value:x:@.arguments/*/html - .lambda - - // Making sure MIME message becomes HTML Content-Type. - set-value:x:../*/mail.smtp.send/**/entity - .:text/html - -// Forward evaluating arguments to [mail.smtp.send]. -unwrap:x:./*/mail.smtp.send/** - -// Sending email. -mail.smtp.send - message - to - . - name:x:@.arguments/*/name - email:x:@.arguments/*/email - from - . - name:x:@.arguments/*/from - email:x:@.arguments/*/from-email - subject:x:@.arguments/*/subject - entity:text/plain - content:x:@.arguments/*/body diff --git a/backend/files/misc/workflows/actions/send-email.hl b/backend/files/misc/workflows/actions/send-email.hl index 3e435a114b..ff450bfd81 100644 --- a/backend/files/misc/workflows/actions/send-email.hl +++ b/backend/files/misc/workflows/actions/send-email.hl @@ -11,6 +11,12 @@ email type:email mandatory:bool:true + from + type:string + mandatory:bool:false + from-email + type:email + mandatory:bool:false subject type:string mandatory:bool:true @@ -28,6 +34,7 @@ validators.mandatory:x:@.arguments/*/email validators.email:x:@.arguments/*/email validators.mandatory:x:@.arguments/*/subject validators.mandatory:x:@.arguments/*/body +validators.email:x:@.arguments/*/from-email // Applying defaults. validators.default:x:@.arguments @@ -42,6 +49,21 @@ if set-value:x:../*/mail.smtp.send/**/entity .:text/html +// Checking if we've got an explicit [from] and [from-email] argument. +if + and + exists:x:@.arguments/*/from + exists:x:@.arguments/*/from-email + .lambda + + // Adding explicit from name/address. + add:x:../*/mail.smtp.send/*/message + . + from + . + name:x:@.arguments/*/from + email:x:@.arguments/*/from-email + // Forward evaluating arguments to [mail.smtp.send]. unwrap:x:./*/mail.smtp.send/**