No results found

Your search did not match any results.

We suggest you try the following to help find what you're looking for:

  • Check the spelling of your keyword search.
  • Use synonyms for the keyword you typed, for example, try "application" instead of "software."
  • Try one of the popular searches shown below.
  • Start a new search.
Trending Questions
 

Sending Emails from OCI with Email Delivery Service in Node.js

Use Oracle Cloud Infrastructure to manage a high-volume email solution for sending out emails to many recipients for critical communications.

Author: Javier Mugueta

Updated:

Oracle Cloud Infrastructure Email Delivery is an email sending service that provides a fast and reliable managed solution for sending high-volume emails that need to reach your recipients’ inbox. Email Delivery provides the tools necessary to send application-generated email for mission-critical communications such as receipts, fraud detection alerts, multi-factor identity verification, and password resets.

Go to a IAM/user and click on [Generate SMTP Credentials] as shown below:

Keep the credentials created in a safe place:

Create an Approved Sender (a real existing email account to put in the from field):

Grab the connection details:

Now test the code:

npm install [nodemailer](https://nodemailer.com/about/)
                    

Create a sendmail.js file:

var nodemailer = require('
                                    nodemailer');
                                    async function main() {
                                    let testAccount = await
                                        nodemailer.createTestAccount();
                                    let transporter = nodemailer.createTransport({
                                        host: "smtp.email.eu-frankfurt-1.oci.oraclecloud.com",
                                        port: 25,
                                        secure: false,
                                        auth: {
                                        user: 'ocid1.user.oc1..aaaaaa...om',
                                        pass: 'BD..._',
                                        },
                                    });
                                    let info = await transporter.sendMail({
                                        from: '"javier...om',
                                        to: "javi...om",
                                        subject: "ssh access to 10.0.2.94",
                                     html: "<b>ssh -i
                                    deltakey -o ProxyCommand=\"ssh -i
                                    deltakey -W %h:%p -p 22
                                    ocid1.bast...oud.com\" -p 22
                                    opc@10.0.2.94</b>",
                                    });
                                    console.log("Message sent: %s", info.messageId);
                                    console.log("Preview URL: %s",
                                        nodemailer.getTestMessageUrl(info));
                                    }
                                    main().catch(console.error);
                                    

Test it:

node sendmail.js
                    

That’s all, hope it helps! 🙂

If you’re curious about the goings-on of Oracle Developers in their natural habitat, come join us on our public Slack channel!

And don’t forget our free tier, where you can try out what we just discussed.