List headers

Nodemailer includes a helper for setting more complex List-* headers with ease. You can use this by providing message option list. It’s an object where key names are converted into list headers. List key help becomes List-Help header etc.

General rules

  • If the value is a string, it is treated as an URL
  • If you want to provide an optional comment, use {url:‘url’, comment: ‘comment’} object
  • If you want to have multiple header rows for the same List-* key, use an array as the value for this key
  • If you want to have multiple URLs for single List-* header row, use an array inside an array
  • List-* headers are treated as pregenerated values, this means that lines are not folded and strings are not encoded. Use only ascii characters and be prepared for longer header lines


1. Setup different List-* headers

let message = {
    from: '',
    to: '',
    subject: 'List Message',
    text: 'I hope no-one unsubscribes from this list!',
    list: {
        // List-Help: <>
        help: '',
        // List-Unsubscribe: <> (Comment)
        unsubscribe: {
            url: '',
            comment: 'Comment'
        // List-Subscribe: <>
        // List-Subscribe: <> (Subscribe)
        subscribe: [
                url: '',
                comment: 'Subscribe'
        // List-Post: <>, <> (Post)
        post: [
                    url: '',
                    comment: 'Post'