Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var nodemailer = require('nodemailer');
- nodemailer.SMTP = {
- host: "smtp.gmail.com",
- port: 465,
- ssl: true,
- use_authentication: true,
- user: "username@gmail.com",
- pass: '###password###'
- };
- var message = {
- sender: 'Sender Email <senderemail@gmail.com>',
- to: '"To Email" <toemail@gmail.com>',
- subject: "Test Sending Email",
- body: "Hello!",
- html:"<p><b>Hello</b> there </p>",
- debug: true
- };
- // Callback to be run after the sending is completed
- var callback = function(error, success){
- if(error){
- console.log("Error occured");
- console.log(error.message);
- return;
- }
- if(success){
- console.log("Message sent successfully!");
- }else{
- console.log("Message failed, reschedule!");
- }
- };
- console.log("Sending Mail");
- // Catch uncaught errors
- process.on("uncaughtException",function(e){
- console.log("Uncaught Exception",e.stack);
- });
- // Send the e-mail
- var mail;
- try{
- mail = nodemailer.send_mail(message, callback);
- }catch(e) {
- console.log("Caught Exception",e);
- }
- var oldemit = mail.emit;
- mail.emit = function(){
- console.log("Mail.emit",arguments);
- oldemit.apply(mail,arguments);
- };
Add Comment
Please, Sign In to add comment