Skip to main content
AutoSend x Nodemailer
Nodemailer is the most popular email sending library for Node.js. By integrating Nodemailer with AutoSend SMTP, you can send transactional emails from your Node.js applications with reliable delivery, full tracking, and detailed analytics.

Prerequisites

Configuration

1

Install Nodemailer

Install the Nodemailer package using your preferred package manager:
npm install nodemailer
2

Create the SMTP Transporter

Configure the Nodemailer transporter with your AutoSend SMTP credentials:
import nodemailer from 'nodemailer';

const transporter = nodemailer.createTransport({
  host: 'smtp.autosend.com',
  port: 465,
  secure: true,
  auth: {
    user: 'autosend',
    pass: 'AS_xxx', // Your AutoSend API key
  },
});
FieldValue
Hostsmtp.autosend.com
Port465 (recommended) or 587
Usernameautosend
PasswordYour AutoSend API key (AS_xxx)
Securetrue for port 465, false for port 587
3

Send an Email

Use the sendMail method to send your email:
const info = await transporter.sendMail({
  from: '[email protected]',
  to: '[email protected]',
  subject: 'Hello from AutoSend',
  html: '<h1>Welcome!</h1><p>This email was sent via Nodemailer and AutoSend SMTP.</p>',
});

console.log('Message sent:', info.messageId);
The from address must use a domain that is verified in AutoSend. For example, if you verified yourdomain.com, use an address like [email protected].
4

Verify Delivery

Check the Email Activity dashboard to verify your email was sent successfully. You’ll see delivery status, opens, clicks, and other engagement metrics.

Complete Examples

import nodemailer from 'nodemailer';

const transporter = nodemailer.createTransport({
	host: 'smtp.autosend.com',
	port: 465,
	secure: true,
	auth: {
		user: 'autosend',
		pass: 'AS_xxx',
	},
});

async function sendEmail() {
	const info = await transporter.sendMail({
		from: '[email protected]',
		to: '[email protected]',
		subject: 'Hello from AutoSend',
		html: '<h1>Welcome!</h1><p>This email was sent via Nodemailer and AutoSend SMTP.</p>',
	});

	console.log('Message sent:', info.messageId);
}

sendEmail().catch(console.error);

Advanced Usage

Sending with Attachments

await transporter.sendMail({
	from: '[email protected]',
	to: '[email protected]',
	subject: 'Email with Attachment',
	html: '<p>Please find the attached file.</p>',
	attachments: [
		{
			filename: 'document.pdf',
			path: './files/document.pdf',
		},
		{
			filename: 'image.png',
			content: imageBuffer,
		},
	],
});

Sending to Multiple Recipients

await transporter.sendMail({
	from: '[email protected]',
	to: '[email protected], [email protected]',
	cc: '[email protected]',
	bcc: '[email protected]',
	subject: 'Hello Everyone',
	html: '<p>This email is sent to multiple recipients.</p>',
});

Plain Text and HTML

await transporter.sendMail({
	from: '[email protected]',
	to: '[email protected]',
	subject: 'Hello from AutoSend',
	text: 'This is the plain text version of the email.',
	html: '<h1>Hello!</h1><p>This is the HTML version of the email.</p>',
});

Troubleshooting

  • Verify your SMTP credentials are correct - Check that your sender email domain is verified in AutoSend - Ensure the from address matches a verified domain - Check your application logs for SMTP connection errors
  • Double-check your API key is correct - Ensure you’re using autosend as the username - Verify your API key is active in the AutoSend dashboard - Make sure there are no extra spaces in the credentials
  • Verify the hostname is smtp.autosend.com - Try using port 587 with secure: false if port 465 fails - Check if your network or firewall blocks outbound SMTP connections - Test connectivity: telnet smtp.autosend.com 465
  • Ensure your domain has proper DNS records (SPF, DKIM, DMARC) - Use a professional sender name and address - Check your domain reputation in AutoSend - Avoid spam trigger words in your email content

Next Steps