sendMail
This procedure can be used to send emails via an SMTP server.
To use it, a properly configured SMTP server is needed. It can be configured using the setSmtpConfiguration
procedure (see below).
Parameters
Parameter | Description |
---|---|
Recipients | Comma-separated list of recipients. May not be an empty string; mandatory |
Subject | Mail subject. May be an empty string; mandatory. |
Body | Mail body. May be an empty string. This parameter will accept both string and clob as input; mandatory |
AttachmentName | Comma-separated list of attachments as shown in the mail; optional |
Attachment | Array of attached files. Inside () - comma-separated list of files; optional |
AttachmentMimeTypes | Array of attachment MIME types for mail delivery; optional |
Usage
CALL "UTILS.sendMail"(
"Recipients" => 'string_Recipients',
"Subject" => 'string_Subject',
"Body" => 'string_Body',
"AttachmentName" => array('string_AttachmentName'),
"Attachment" => array(blob_Attachment),
"AttachmentMimeType" => array('string_AttachmentMimeType')
)
Example
In this example, we are sending an email with two attachments:
CALL "UTILS.sendMail"(
"Recipients" => 'example@example.org',
"Subject" => 'Testmail',
"Body" => 'Hello world.',
"Attachments" => array(
(SELECT file FROM (CALL "file.getFiles"() ) a WHERE a.filePath like 'currencyconvertor.asmx'),
(SELECT file FROM (CALL "file.getFiles"() ) a WHERE a.filePath like 'currencyconvertor.wsdl')
),
"AttachmentNames" => array('currencyconvertor.asmx', 'currencyconvertor.wsdl'),
"AttachmentMimeTypes" => array('application/asmx', 'application/wsdl')
) ;;
Error Messages and Troubleshooting
Error | Solution |
---|---|
JavaException: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 455 | Please check that you have entered the correct server host address and port. For example, '<remote-destination host="smtp.gmail.com" port="465"/>' is correct, but the above message shows that the wrong port was used |
JavaException: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 455, response: -1 | Please check the SSL settings. Having <smtp-server ssl="false" outbound-socket-binding-ref="mail-smtp"> but connecting to a secure port will lead to this error |
JavaException: javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at535 5.7.8 http://support.google.com/mail/bin/answer.py?answer=14257 xm4sm2073790wib.9 - gsmtp | Please check that you have entered the correct credentials |
See Also
Email Notification with Editable FROM Address for a short guide on how to set up failed jobs notifications using a different FROM address