deno function - smtp - works locally but fails remote
Hello, I have a deno function triggering a SendGrid email that works locally but fails on remote. this is the log of the error
here is the key section of the function
TimedOut: Connection timed out (os error 110)
at async Object.connect (deno:ext/net/01_net.js:333:17)
at async SmtpClient.connect (file:///src/main.ts:857:22)
at async Server.<anonymous> (file:///src/main.ts:1173:5)
at async Server.#respond (file:///src/main.ts:111:24)
Severity
ERROR
Deployment version3
Timestamp16 Oct, 2022 09:41
Execution ID43ccbd3e-63eb-43bb-9ab6-06f58bc38ea0TimedOut: Connection timed out (os error 110)
at async Object.connect (deno:ext/net/01_net.js:333:17)
at async SmtpClient.connect (file:///src/main.ts:857:22)
at async Server.<anonymous> (file:///src/main.ts:1173:5)
at async Server.#respond (file:///src/main.ts:111:24)
Severity
ERROR
Deployment version3
Timestamp16 Oct, 2022 09:41
Execution ID43ccbd3e-63eb-43bb-9ab6-06f58bc38ea0here is the key section of the function
await smtp.connect({
hostname: String(Deno.env.get('SENDGRID_SMTP_HOSTNAME')),
port: Number(Deno.env.get('SENDGRID_SMTP_PORT')),
username: String(Deno.env.get('SENDGRID_SMTP_USERNAME')),
password: String(Deno.env.get('SENDGRID_SMTP_PASSWORD')),
});
try {
await smtp.send({
from: String(Deno.env.get('SENDGRID_SMTP_FROM')),
to: payload.to,
subject: payload.subject,
content: payload.content,
});
} catch (error) {
return new Response(error.message, { status: 500 });
}
await smtp.close(); await smtp.connect({
hostname: String(Deno.env.get('SENDGRID_SMTP_HOSTNAME')),
port: Number(Deno.env.get('SENDGRID_SMTP_PORT')),
username: String(Deno.env.get('SENDGRID_SMTP_USERNAME')),
password: String(Deno.env.get('SENDGRID_SMTP_PASSWORD')),
});
try {
await smtp.send({
from: String(Deno.env.get('SENDGRID_SMTP_FROM')),
to: payload.to,
subject: payload.subject,
content: payload.content,
});
} catch (error) {
return new Response(error.message, { status: 500 });
}
await smtp.close();