From: Kevin B. <kev...@xp...> - 2021-10-29 19:43:53
|
We use multiple servers depending on PROD/QA/DEV as well as eXist-db locations in territories in the world. I cut one down to show you what we use. This sets the appropriate properties for the mail session using the credentials for the IAM user for sending email: declare variable $g:server.mail.properties := <properties> <property name="mail.smtp.host" value="email-smtp.eu-west-1.amazonaws.com"/> <property name="mail.smtp.starttls.enable" value="true"/> <property name="mail.smtp.port" value="587"/> <property name="mail.smtp.auth" value="true"/> <property name="mail.smtp.allow8bitmime" value="true"/> <property name="mail.smtp.user" value="XXXXXXXXXXXXXXXXXX"/> <property name="mail.smtp.password" value="XXXXXXXXXXXXXXXXXXXXXXXXX"/> </properties>; Then a simple function like below to send email given cc, bcc, subject, html body and attachements: declare function xport:send-email2($to as item()*, $cc as item()*, $bcc as item()*, $alternateFromDisplay as xs:string, $subject as xs:string, $html as element(), $text as xs:string, $attachments as item()*) as element()* { let $from := if(normalize-space($alternateFromDisplay) = '') then $g:server.mail-from-address else concat($alternateFromDisplay, ' <', $g:server.mail-no-reply, '>') let $message := <mail> <from>{$from}</from> { for $email in $to return <to>{$email}</to> } { for $email in $cc return <cc>{$email}</cc> } { for $email in $bcc return <bcc>{$email}</bcc> } <subject>{$subject}</subject> <message> <text>{$text}</text> <xhtml>{$html}</xhtml> </message> { for $attachment in $attachments/* return $attachment } </mail> let $mailsession := mail:get-mail-session($g:server.mail.properties) return mail:send-email($mailsession, $message) } ; Kevin From: Len Schultz <le...@wi...> Sent: Thursday, October 28, 2021 12:24 PM To: exist-open <exi...@li...> Subject: [Exist-open] Sending mail via Amazon SES Has anyone successfully sent email via Amazon SES via exist-db? I’m sure I could get it working, but if there are any modules that do this already, any pointers would be greatly appreciated. --len |