How to use the mailparser.MailParser function in mailparser

To help you get started, we’ve selected a few mailparser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nomospace / nodemail / demo / mailparser / demo2 / mail-parser.js View on Github external
var MailParser = require("mailparser").MailParser,
    mailparser = new MailParser();

var email = "From: 'Sender Name' \r\n"+
            "To: 'Receiver Name' \r\n"+
            "Subject: Hello world!\r\n"+
            "\r\n"+
            "How are you today?";

// setup an event listener when the parsing finishes
mailparser.on("end", function(mail_object){
    console.log("From:", mail_object.from); //[{address:'sender@example.com',name:'Sender Name'}]
    console.log("Subject:", mail_object.subject); // Hello world!
    console.log("Text body:", mail_object.text); // How are you today?
});

// send the email source to the parser
mailparser.write(email);
github oaeproject / Hilary / node_modules / oae-email / lib / api.js View on Github external
emailTransport.sendMail(emailInfo, function(err, info) {
                    if (err) {
                        log().error({'err': err, 'to': emailInfo.to, 'subject': emailInfo.subject}, 'Error sending email to recipient');
                        return callback(err);
                    }
                    // If we're debugging we log the mail that would have been sent
                    if (debug) {
                        log().info({'to': emailInfo.to, 'subject': emailInfo.subject}, 'Sending email');

                        // Parse the email so our unit tests can inspect the result
                        var mailparser = new MailParser();
                        mailparser.on('end', function(email_object){
                            EmailAPI.emit('debugSent', email_object);
                            return callback();
                        });
                        mailparser.write(info.response);
                        mailparser.end();
                    } else {
                        return callback();
                    }
                });
            });
github RedMail / RedMail / ts.js View on Github external
var smtp = require('smtp-protocol'); 
import { MailParser } from 'mailparser'
var mailparser = new MailParser();
var concat = require('concat-stream');
var data = ''

mailparser.on("end", function(mail_object){
  // console.log(mail_object)
})

var server = smtp.createServer(function(req) {
  req.on('greeting', function(to, ack) {   
    console.log(to)  // 这里是刚才的 helo 之后的回调  
    ack.accept();
  });

  req.on('from', function(to, ack) {  
    console.log(to) // 输入过发信人后的回调 mail from:
    ack.accept();
github adonisjs / adonis-mail / test / unit / log.spec.js View on Github external
co(function * () {
      const message = new Message()
      message.to('virk@foo.com')
      message.header([{key: 'x-id', value: 2}, {key: 'x-user', value: 'doe'}])
      message.from('virk@bar.com')
      message.subject('Hello world')
      message.html('<h2>Hello world</h2>')
      message.text('Hello world')
      const log = new Log(Config)
      yield log.send(message.data)
      const mailparser = new MailParser()

      const emailLogs = yield fs.readFile(Config.get().toPath, 'utf8')
      const email = emailLogs.split(/-\s?Email Start\s?-/gi).pop().replace(/-\s?EMAIL END\s?-/i, '').trim()

      mailparser.on('end', function (mailObject) {
        expect(mailObject.headers['x-id']).to.equal('2')
        expect(mailObject.headers['x-user']).to.equal('doe')
        done()
      })

      mailparser.write(email)
      mailparser.end()
    })
  })
github sawyerh / highlight-utils / packages / highlights-lambda / debugging.js View on Github external
const _import = function _import() {
  const mailparser = new MailParser();
  mailparser.on("end", function(mail) {
    const plaintext = new Plaintext(mail);

    console.log("Parseable: ", plaintext.parseable());
    console.log(plaintext.parse(mail));
  });
  fs.createReadStream(path.resolve("exports/text-email")).pipe(mailparser);
};
github ronny3050 / email-mirror / notifier.js View on Github external
fetch.on('message', function (msg) {
            var mp = new MailParser();
            var s = null;
            mp.once('end', function (mail) {
                self.emit('mail', mail, s);
                dbg(s);
            });
            msg.once('body', function (stream, info) {
                stream.pipe(mp);
                s = info.seqno;
            });
        });
        fetch.once('end', function () {
github colinking / n1-unsubscribe / lib / thread-unsubscribe-store.es6 View on Github external
const success = (rawEmail) => {
          const mailparser = new MailParser();
          mailparser.on('end', (parsedEmail) => {
            callback(null, parsedEmail);
          });
          mailparser.write(rawEmail);
          mailparser.end();
        };
        const error = (error) => {
github SibirixScrum / HelpDesk / models / mail.js View on Github external
f.on('message', function(msg, seqno) {
                var mailParser = new MailParser();

                mailParser.on('end', processMailObject);

                msg.on('body', function(stream, info) {
                    stream.on('data', function(chunk) {
                        mailParser.write(chunk);
                    });
                });

                msg.once('end', function() {
                    mailParser.end();
                });
            });
github jmosbech / mail-null / smtp.js View on Github external
function (req) {
		var mailparser = new MailParser();
		mailparser.on('end', function (email) {
			email.attachments = (email.attachments||[]).map(function(attachment){
				attachment.content = attachment.content.toString('base64');
				return attachment;
			});
			storage.push(email);
		});
		req.pipe(mailparser);
		req.accept();
	}).listen(port);
github divshot / superstatic-forms / lib / response.js View on Github external
function parseMailHeaders (headers, callback) {
  var mailparser = new MailParser();
  mailparser.once('end', callback);
  mailparser.write(headers);
  mailparser.end();
}

mailparser

Parse e-mails

MIT
Latest version published 9 days ago

Package Health Score

83 / 100
Full package analysis

Similar packages