Skip to content
New issue

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

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

Already on GitHub? # to your account

Form is not posting. #1

Open
yilmazbingo opened this issue May 23, 2019 · 2 comments
Open

Form is not posting. #1

yilmazbingo opened this issue May 23, 2019 · 2 comments

Comments

@yilmazbingo
Copy link

I even copied and pasted exact code but I get same error:

jquery-3.3.1.min.js:2 POST http://localhost:3000/email 404 (Not Found)

Since I log the ajax requests on console, I also get this:
jquery-3.3.1.min.js:2 XHR failed loading: POST

I tested jquery with different commands and jquery is working fine.
I thought issue might be because of parsing data, so I installed body-parser module didnt help.
Since I saw the ajax error, I was suspecting cross origin policy error. So I added some code to circumvent cross origin policy, I got this error:

:3000/email:1 Failed to load resource: the server responded with a status of 404 (Not Found)

@accimeesterlin
Copy link
Owner

Hey @yilmazbingo,
The server is running on PORT 8080, not 3000. You might need to try to run the example app on http://localhost:8080, and try to send an email again. I updated the README.md and also added some TODO across the codebase so that you can follow along as well. Hope this helps. If you're still running into issues, please share a link to your github repo where the code is hosted, and I can take a look at it. Thanks

@mdasiff
Copy link

mdasiff commented May 31, 2020

Error occursTypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined.

Plz help

const express = require("express");
const router = express.Router();

const nodemailer = require('nodemailer');
const hbs = require('nodemailer-handlebars');
const log = console.log;

router.get("/mail", (req, res) => {

// Step 1
let transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: 'okbozo007@gmail.com',
pass: 'mypass'
}
});

// Step 2
transporter.use('compile', hbs({
viewEngine: 'express-handlebars',
viewPath: './views/'
}));

// Step 3
let mailOptions = {
from: 'md.asif@okbozo.com',
to: 'mdasiff007@gmail.com',
subject: 'Nodemailer - Test',
text: 'Wooohooo it works!!',
template: 'index',
context: {
name: 'Accime Esterling'
} // send extra values to template
};

// Step 4
transporter.sendMail(mailOptions, (err, data) => {
if (err) {
return log('Error occurs' + err);
}
return log('Email sent!!!');
});

});

module.exports = router;

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

No branches or pull requests

3 participants