Skip to content

Nodemailer does not work #3003

@Akumzy

Description

@Akumzy

What version of Bun is running?

0.6.2

What platform is your computer?

Darwin 22.4.0 arm64 arm

What steps can reproduce the bug?

'use strict';
import nodemailer from 'nodemailer';

// async..await is not allowed in global scope, must use a wrapper
async function main() {
  // Generate test SMTP service account from ethereal.email
  // Only needed if you don't have a real mail account for testing
  const transporter = nodemailer.createTransport({
    host: 'smtp.ethereal.email',
    port: 587,
    secure: false, // true for 465, false for other ports
    auth: {
      user: '...',
      pass: '...',
    },
  });

  // send mail with defined transport object
  let info = await transporter.sendMail({
    from: '"Fred Foo 👻" <foo@example.com>', // sender address
    to: 'example@gmail.com', // list of receivers
    subject: 'Hello ✔', // Subject line
    text: 'Hello world?', // plain text body
    html: '<b>Hello world?</b>', // html body
  });

  console.log('Message sent: %s', info.messageId);
  // Message sent: <b658f8ca-6296-ccf4-8306-87d57a0b4321@example.com>

  // Preview only available when sending through an Ethereal account
  console.log('Preview URL: %s', nodemailer.getTestMessageUrl(info));
  // Preview URL: https://ethereal.email/message/WaQKMgKddxQDoou...
}

main().catch(console.error);

What is the expected behavior?

To send email successfully

What do you see instead?

Depending on the SMTP credentials I'm getting different errors

1371 |             return;
1372 |         }
1373 | 
1374 |         this._upgradeConnection((err, secured) => {
1375 |             if (err) {
1376 |                 this._onError(new Error('Error initiating TLS - ' + (err.message || err)), 'ETLS', false, 'STARTTLS');
                                 ^
error: Error initiating TLS - Expected "port" to be a number between 0 and 65535
 code: "ETLS"

      at /Users/[redacted]/node_modules/nodemailer/lib/smtp-connection/index.js:1376:30
      at _actionSTARTTLS (/Users/[redacted]/node_modules/nodemailer/lib/smtp-connection/index.js:1374:8)

and also

error: DNS lookup failed: Given hostname is not numeric
 code: "EDNS"

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingnode.jsCompatibility with Node.js APIs

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions