Forum OpenACS Q&A: Response to Send mail from PL/SQL

Collapse
Posted by Daryl Biberdorf on

Tom Kyte's site has a nice entry on sending mail from PL/SQL using the UTL_SMTP package.

I've got more experience than I'd like to have sending email from PL/SQL. With that in mind, there are some pros and cons of UTL_SMTP:
Pros

  • using it requires nothing but PL/SQL
  • it's simple and straightforward
Cons
  • you can't send attachments with it, unless you want to write all the stuff to build a multi-part message and base64 encoding and all that yourself
  • it's a bit limiting at times

I originally wrote a thing that sent automated email using UTL_SMTP. Later on, I wrote another thing that needed to send automated email (on a different basis) with attachments. The latter forced me into using the JavaMail API. When I get the chance, I'll be altering the former code to use the latter set of routines.

Kyte's book has some helpful samples for interfacing PL/SQL to JavaMail.

Neither JavaMail nor UTL_SMTP deal all that well with transient MTA errors. I recommend having a very available SMTP server nearby for that reason.