Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Nodemailer transporters #135

Open
ohbob opened this issue Dec 10, 2023 · 1 comment
Open

Multiple Nodemailer transporters #135

ohbob opened this issue Dec 10, 2023 · 1 comment

Comments

@ohbob
Copy link

ohbob commented Dec 10, 2023

Feature request

Use multiple transporters

Summary

Quick summary what's this feature request about.
I would like to send emails from several domains, as my backend hosts several domains.

Why is it needed?

I want clients to receive emails from the domain that is associated with the project

Suggested solution(s)

I know i can manually send from several transporters but i have no idea on how to use it with your layouts.

const nodemailer = require('nodemailer');

// Transporter for the first identity
const transporter1 = nodemailer.createTransport({
    host: 'smtp.first-server.com',
    port: 587,
    secure: false, // true for 465, false for other ports
    auth: {
        user: 'user1@example.com',
        pass: 'password1'
    }
});

// Transporter for the second identity
const transporter2 = nodemailer.createTransport({
    host: 'smtp.second-server.com',
    port: 587,
    secure: false, // true for 465, false for other ports
    auth: {
        user: 'user2@example.com',
        pass: 'password2'
    }
});

// Example of sending an email with the first identity
transporter1.sendMail({
    from: 'user1@example.com',
    to: 'recipient@example.com',
    subject: 'Email from first identity',
    text: 'This is the email content.'
}, (err, info) => {
    if (err) {
        console.error(err);
    } else {
        console.log('Email sent: ' + info.response);
    }
});

// Example of sending an email with the second identity
transporter2.sendMail({
    from: 'user2@example.com',
    to: 'recipient@example.com',
    subject: 'Email from second identity',
    text: 'This is the email content.'
}, (err, info) => {
    if (err) {
        console.error(err);
    } else {
        console.log('Email sent: ' + info.response);
    }
}); 

A clear and concise description of what you want to happen.

Suggest a solution

Related issue(s)/PR(s)

Let us know if this is related to any issue/pull request.

Copy link

Thank you!! This is your first issue on this repo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant