Venkatesan R
Venkatesan R

Reputation: 1

How to send email using angular 9

The following code send email from server side. How to I use that code in Angular 9 application. Could you please help some one for this.

    var nodemailer = require('nodemailer');

    var transporter = nodemailer.createTransport({
    service: 'gmail',
    auth: {
    user: '[email protected]',
    pass: 'xxxx'
    }
    });

    var mailOptions = {
    from: '[email protected]',
    to: '[email protected]',
    subject: 'Sending Email using Node.js',
    text: `Hi, thank you for your nice Node.js Email.`
    };

    transporter.sendMail(mailOptions, function(error, info){
    if (error) {
    console.log(error);
    } else {
    console.log('Email sent: ' + info.response);
    }
    });

Upvotes: 0

Views: 6478

Answers (1)

Christiano Marques
Christiano Marques

Reputation: 41

Probably, the above code will works i the Angular application, but the big problem doing that, is you will have exposed mail transport credentials in your front app. As mentioned before, best solution is create a simple API that send the email on server side.

Upvotes: 1

Related Questions