Skip to main content
Skip table of contents

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

ParameterDescription
RecipientsComma-separated list of recipients. May not be an empty string; mandatory
SubjectMail subject. May be an empty string; mandatory.
BodyMail body. May be an empty string. This parameter will accept both string and clob as input; mandatory
AttachmentNameComma-separated list of attachments as shown in the mail; optional
AttachmentArray of attached files. Inside () - comma-separated list of files; optional
AttachmentMimeTypesArray of attachment MIME types for mail delivery; optional

Usage

SQL
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:

SQL
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

ErrorSolution
JavaException: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 455Please 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: -1Please 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 - gsmtpPlease 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

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.