Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- app.post('/', emailUtility.sendMail, function(req, res) {
- res.send("recieved your request!");
- });
- var nodemailer = require('nodemailer');
- exports.sendMail = function(req, res, next) {
- var input = JSON.parse(JSON.stringify(req.body));
- var data = {
- persons_name: input.name,
- personal_message: input.message
- };
- console.log("name :" + data.persons_name);
- console.log("message :" + data.personal_message);
- // Generate test SMTP service account from ethereal.email
- // Only needed if you don't have a real mail account for testing
- nodemailer.createTestAccount((err, account) => {
- // create reusable transporter object using the default SMTP transport
- let transporter = nodemailer.createTransport({
- host: 'smtp.gmail.com',
- port: 587,
- secure: false, // true for 465, false for other ports
- auth: {
- user: process.env.USERNAME, // generated ethereal user
- pass: process.env.PASS // generated ethereal password
- }
- });
- // setup email data with unicode symbols
- let mailOptions = {
- from: data.persons_name + '" 👻" <example@gmail.com>', // sender address
- to: process.env.MAILTOSENDTO, // list of receivers
- subject: 'Art Life Clothing ✔', // Subject line
- text: data.personal_message, // plain text body
- html: '<b>' + data.personal_message + '</b>' // html body
- };
- // send mail with defined transport object
- transporter.sendMail(mailOptions, (error, info) => {
- if (error) {
- return console.log(error);
- }
- console.log('Message sent: %s', info.messageId);
- // Preview only available when sending through an Ethereal account
- console.log('Preview URL: %s', nodemailer.getTestMessageUrl(info));
- // Message sent: <b658f8ca-6296-ccf4-8306-87d57a0b4321@example.com>
- // Preview URL: https://ethereal.email/message/WaQKMgKddxQDoou...
- });
- });
- next()
- }
- at=info method=POST path="/" host=calm-island-58460.herokuapp.com request_id=ca397146-1296-42a8-a505-b2c6ebb1543a fwd="197.229.3.109" dyno=web.1 connect=0ms service=152ms status=200 bytes=222 protocol=https
- 2018-12-30T17:06:32.673329+00:00 app[web.1]: dns.js:229
- 2018-12-30T17:06:32.673336+00:00 app[web.1]: throw new Error('"callback" argument must be a function');
- 2018-12-30T17:06:32.673338+00:00 app[web.1]: ^
- 2018-12-30T17:06:32.673340+00:00 app[web.1]:
- 2018-12-30T17:06:32.673344+00:00 app[web.1]: Error: "callback" argument must be a function
- 2018-12-30T17:06:32.673346+00:00 app[web.1]: at Object.query [as resolve4] (dns.js:229:13)
- 2018-12-30T17:06:32.673348+00:00 app[web.1]: at resolver (/app/node_modules/nodemailer/lib/shared/index.js:15:28)
- 2018-12-30T17:06:32.673350+00:00 app[web.1]: at Object.module.exports.resolveHostname (/app/node_modules/nodemailer/lib/shared/index.js:55:5)
- 2018-12-30T17:06:32.673351+00:00 app[web.1]: at SMTPConnection.connect (/app/node_modules/nodemailer/lib/smtp-connection/index.js:314:27)
- 2018-12-30T17:06:32.673353+00:00 app[web.1]: at getSocket (/app/node_modules/nodemailer/lib/smtp-transport/index.js:262:24)
- 2018-12-30T17:06:32.673355+00:00 app[web.1]: at Immediate.setImmediate (/app/node_modules/nodemailer/lib/smtp-transport/index.js:70:35)
- 2018-12-30T17:06:32.673357+00:00 app[web.1]: at runCallback (timers.js:570:20)
- 2018-12-30T17:06:32.673358+00:00 app[web.1]: at tryOnImmediate (timers.js:550:5)
- 2018-12-30T17:06:32.673360+00:00 app[web.1]: at processImmediate [as _immediateCallback] (timers.js:529:5)
- 2018-12-30T17:06:32.767524+00:00 heroku[web.1]: State changed from up to crashed
- 2018-12-30T17:06:32.749958+00:00 heroku[web.1]: Process exited with status 1
Add Comment
Please, Sign In to add comment