@unitybase/mailer

Module for send and receive mail. ssl is not supported. If you need SSL connection - use @unitybase/mailer-ssl

WARNING - do not send a mail directly from a HTTP thread. Mail server can fail or work slowly. The rigth way is to put a mail messages in the queue and send it via scheduler.

UBQ model already have:

  • a module 'modules/mail-queue` for addint EMails to queue
  • a mail scheduler job for sending a mail from queue (once a minute by default)

Usage sample:

  const UBMail = require('@unitybase/mailer')
  // send e-mail
  let sender = new UBMail.TubMailSender({
    host: 'mail.host.name',
    port: '25',
    tls: false
  })
  sender.sendMail({
    subject: 'subject 1',
    bodyType: UBMail.TubSendMailBodyType.Text,
    body: 'body\r\n 1',
    fromAddr: mailAddr1,
    toAddr: [mailAddr1, mailAddr2]
  })

  // Receive e-mails
  let receiver = new UBMail.TubMailReceiver({
    host: mailHost,
    port: '110',
    tls: false,
    auth: true,
    user: 'mpv',
    password: 'myPassword'
  })
  receiver.reconnect();
  let cnt = r.getMessagesCount()
  let res = []
  for (let i = 1; i <= cnt; i++ ) {
      res.push(r.receive(i))
  }

Classes

TubMailReceiverBind
TubMailSenderBind
TubMimeMessBind
StringCollectionBind
TMessHeaderBind
TMimePartBind

Members

TubSendMailBodyTypeBind: Number inner constant

Properties:
Name Type Description
Text Number
HTML Number
Calendar Number

TubSendMailAttachKindBind: Number inner constant

Properties:
Name Type Description
File Number
Text Number
Buffer Number

Methods

TubMailReceiver()TubMailReceiverBind inner

constructor for TubMailReceiver

TubMailSender()TubMailSenderBind inner

constructor for TubMailSender

Classes

TubMailReceiverBind
TubMailSenderBind
TubMimeMessBind
StringCollectionBind
TMessHeaderBind
TMimePartBind

Members

TubSendMailBodyTypeBind: Number inner constant

Properties:
Name Type Description
Text Number
HTML Number
Calendar Number

TubSendMailAttachKindBind: Number inner constant

Properties:
Name Type Description
File Number
Text Number
Buffer Number

Methods

TubMailReceiver()TubMailReceiverBind inner

constructor for TubMailReceiver

TubMailSender()TubMailSenderBind inner

constructor for TubMailSender