Simple Node.js/Express app using Nodemailer to send emails
- Please add your own SMTP info for it to work
1.0.0
npm install
node app
Node.js app that uses nodemailer to send emails
app.engine('handlebars', exphbs());
^
TypeError: exphbs is not a function
at Object. (C:\Users\91977\Desktop\nodecontactform-master\app.js:10:26)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47
facing issue from this line in app.js file:
let transporter = nodemailer.createTransport({ host: "smtp.gmail.com", port: 465, secure: true, // true for 465, false for other ports auth: { user: '****@gmail.com', pass: '*****' }, tls:{ rejectUnauthorized:false } });
and giving an error in the terminal
Server started...
{ Error: Invalid login: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8 https://support.google.com/mail/?p=BadCredentials s68sm6561971pjb.38 - gsmtp
at SMTPConnection._formatError (/home/rupb/Desktop/nodemail/node_modules/nodemailer/lib/smtp-connection/index.js:784:19)
at SMTPConnection._actionAUTHComplete (/home/rupb/Desktop/nodemail/node_modules/nodemailer/lib/smtp-connection/index.js:1523:34)
at SMTPConnection._responseActions.push.str (/home/rupb/Desktop/nodemail/node_modules/nodemailer/lib/smtp-connection/index.js:550:26)
at SMTPConnection._processResponse (/home/rupb/Desktop/nodemail/node_modules/nodemailer/lib/smtp-connection/index.js:942:20)
at SMTPConnection._onData (/home/rupb/Desktop/nodemail/node_modules/nodemailer/lib/smtp-connection/index.js:749:14)
at TLSSocket.SMTPConnection._onSocketData.chunk (/home/rupb/Desktop/nodemail/node_modules/nodemailer/lib/smtp-connection/index.js:195:44)
at TLSSocket.emit (events.js:198:13)
at addChunk (_stream_readable.js:288:12)
at readableAddChunk (_stream_readable.js:269:11)
at TLSSocket.Readable.push (_stream_readable.js:224:10)
code: 'EAUTH',
response:
'535-5.7.8 Username and Password not accepted. Learn more at\n535 5.7.8 https://support.google.com/mail/?p=BadCredentials s68sm6561971pjb.38 - gsmtp',
responseCode: 535,
command: 'AUTH PLAIN' }
My email id and password is correct but still facing this error.
If you get this error below
Error: ENOENT: no such file or directory
1-solution
A-Create views folder look like this:
views
|—— layouts
| |
| |—main.handlebars
|
|—concat.handlebars
B-Then
main.handlebars will be templated below
<!DOCTYPE html>
<html lang="en">
…
<body>
{{{body}}}
</body>
</html>
concat.handlebars will be templated below
<div class="container">
…..
</div>
Or
2-solution
in app.js use res.render('contact', {layout: false});
instead of res.render('contact');
let transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: '',
pass: ''
}
});
hey why iam getting this error
Error: ENOENT: no such file or directory, open 'C:\Users\HP\Desktop\f\nodecontactform-master\views\layouts\main.handlebars'
note: smtp details are updated
This is what I get When I download, extract and type node app to run
module.js:549
throw err;
^
Error: Cannot find module 'express-handlebars'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object. (C:\Users\nam,e\Downloads\nodecontactform-master\nodecontactform-master\app.js:3:16)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.