My project uses Nodemailer to send service emails from the server. The code runs fine on my local environment, but when deployed to Cloud Foundry, it times out on the email sending connection.
Using SSH into the app container, curl google.com
works, but curl --ssl smtp://smtp.email.uk-london-1.oci.oraclecloud.com
doesn't work and times out.
Where and how could I configure this network access?
/sendEmail.ts
export async function sendEmail(toEmail): Promise<<SMTPTransport.SentMessageInfo> {
const transporter = nodemailer.createTransport({
host: ENDPOINTS.smtp.endpoint,
port: ENDPOINTS.smtp.port,
secure: false,
requireTLS: true,
auth: {
user: ENDPOINTS.smtp.credentials.id,
pass: ENDPOINTS.smtp.credentials.pass
}
});
return
await transporter.sendMail({
from: ...,
to: toEmail,
subject: ...
text: ...,
html: ...
})
}
const ENDPOINTS = {
smtp: {
endpoint: 'smtp.email.uk-london-1.oci.oraclecloud.com',
port: 25,
from: 'accounts-noreply@example.com',
credentials: {
id: ...,
pass: ...
}
}
}
Try port 587 instead of port 25. Typically, port 25 is used by SMTP for unencrypted transfer, port 587 for SSL/TLS-based encrpyted transfer. Often, the port 25 is blocked because of frequent misuse.
For my projects, I usually don't even bother using port 25, but directly try 587.