denoland / deploy_feedback

For reporting issues with Deno Deploy
https://deno.com/deploy
74 stars 5 forks source link

[Bug]: NodeMailer Not working #701

Closed 2u841r closed 1 month ago

2u841r commented 1 month ago

Problem description

in local computer
deno run -A main.js working, but not in deno-deploy.

and from Github repo to Deno deploy import - The deployment failed: ISOLATE_INTERNAL_FAILURE

Code is

import nodemailer from 'npm:nodemailer'

// Create a transporter object using SMTP transport
const transporter = nodemailer.createTransport(
    {
        secure: true,
        host: 'smtp.gmail.com',
        port: 465,
        auth: {
            user: 'mygmail@gmail.com',
            pass: 'hereIsMyPass'
        }
    }
);

// Define email options
const mailOptions = {
    from: 'mygmail@gmail.com', // Sender address
    to: 'mygmail2@gmail.com', // List of receivers
    subject: 'You One Time Link', // Subject line
    text: 'Hello world!', // Plain text body
    html: '<b>Hello world!</b>' // HTML body
};

// Send email
transporter.sendMail(mailOptions, (error, info) => {
    if (error) {
        return console.log('Error: ', error);
    }
    console.log('Email sent: ' + info.response);
});

Error

error is (playground, before export to github) 1 Error sending email: Error: connect ECONNREFUSED 142.251.10.109:465 - Local (undefined:undefined) at __node_internal_captureLargerStackTrace (ext:deno_node/internal/errors.ts:93:9) at __node_internal_exceptionWithHostPort (ext:deno_node/internal/errors.ts:217:10) at TCPConnectWrap._afterConnect [as oncomplete] (node:net:171:16) at TCP.afterConnect (ext:deno_node/internal_binding/connection_wrap.ts:43:11) at TCP.handle.afterConnect (ext:deno_node/_tls_wrap.ts:129:29) at eventLoopTick (ext:core/01_core.js:168:7) { errno: -111, code: "ESOCKET", syscall: "connect", address: "142.251.10.109", port: 465, localAddress: undefined, localPort: undefined, command: "CONN" } so localAddress: undefined, localPort: undefined,

and from Github repo to Deno deploy import - The deployment failed: ISOLATE_INTERNAL_FAILURE

Steps to reproduce

create a gmail App passwords (after enabling 2FA) from https://myaccount.google.com/apppasswords

Then create a file with those code deno run -A --watch main.js working on local, not in deno deploy.

Expected behavior

send an email from nodemailer + deno deploy

Environment

No response

Possible solution

No response

Additional context

No response

magurotuna commented 1 month ago

Hi @2u841r, it looks like your code is trying to access TCP port 465, which is unfortunately rejected by our network policy to prevent abuse. Could you consider another solution like REST-API based emailing services? Thank you for your understanding.