Having a slight issue with an email function. I experimented with the 'nodemailer' package and successfully sent an email when coding in a .js file. Upon calling the .js file (node emailfile.js), the email was received as expected (code provided below).
var nodemailer = require('nodemailer');
let transporter = nodemailer.createTransport({
service: 'gmail',
secure: false,
port: 25,
auth: {
user: 'MYUSERNAME', // for privacy reasons
pass: 'ok1994ka'
},
tls: {
rejectUnauthorized: false
}
});
let HelperOptions = {
from: '"Sportot App" <<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="66000f1c0f090e090b0326010b">[email protected]</a>>',
to: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="690f001300060106040c290e">[email protected]</a>',
subject: 'Hello World',
text: 'Good day to you!'
};
transporter.sendMail(HelperOptions, (error, info) => {
if (error) {
return console.log("error");
}
console.log("Email sent");
});
Now, my goal is to call this .js file from within my HTML file.
<button ion-button block color="danger" (click)=pasts()>Send Email</button>
In the html file, between script tags, I added:
<script src="email.js"></script>
I also included "function pasts(){...}" inside with all the code from email.js file. Hopefully, someone can provide insight. Thank you!