strapi-plugin-email-designer icon indicating copy to clipboard operation
strapi-plugin-email-designer copied to clipboard

Multiple Nodemailer transporters

Open ohbob opened this issue 7 months ago • 1 comments

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: '[email protected]',
        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: '[email protected]',
        pass: 'password2'
    }
});

// Example of sending an email with the first identity
transporter1.sendMail({
    from: '[email protected]',
    to: '[email protected]',
    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: '[email protected]',
    to: '[email protected]',
    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.

ohbob avatar Dec 10 '23 23:12 ohbob