dist/utils.js
function encodeHeaderValue(key) {
  var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';

  key = normalizeHeaderKey(key);

  switch (key) {
    case 'From':
    case 'Sender':
    case 'To':
    case 'Cc':
    case 'Bcc':
    case 'Reply-To':
      return convertAddresses(parseAddresses(value));

    case 'Message-Id':
    case 'In-Reply-To':
    case 'Content-Id':
      value = value.replace(/\r?\n|\r/g, ' ');

      if (value.charAt(0) !== '<') {
        value = '<' + value;
      }

      if (value.charAt(value.length - 1) !== '>') {
        value = value + '>';
      }
      return value;

    case 'References':
      value = [].concat.apply([], [].concat(value).map(function () {
        var elm = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
        return elm.replace(/\r?\n|\r/g, ' ').trim().replace(/<[^>]*>/g, function (str) {
          return str.replace(/\s/g, '');
        }).split(/\s+/);
      })).map(function (elm) {
        if (elm.charAt(0) !== '<') {
          elm = '<' + elm;
        }
        if (elm.charAt(elm.length - 1) !== '>') {
          elm = elm + '>';
        }
        return elm;
      });

      return value.join(' ').trim();

    default:
      return (0, _emailjsMimeCodec.mimeWordsEncode)((value || '').toString().replace(/\r?\n|\r/g, ' '), 'B');
  }
}
function encodeHeaderValue(key) {
  var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';

  key = normalizeHeaderKey(key);

  switch (key) {
    case 'From':
    case 'Sender':
    case 'To':
    case 'Cc':
    case 'Bcc':
    case 'Reply-To':
      return convertAddresses(parseAddresses(value));

    case 'Message-Id':
    case 'In-Reply-To':
    case 'Content-Id':
      value = value.replace(/\r?\n|\r/g, ' ');

      if (value.charAt(0) !== '<') {
        value = '<' + value;
      }

      if (value.charAt(value.length - 1) !== '>') {
        value = value + '>';
      }
      return value;

    case 'References':
      value = [].concat.apply([], [].concat(value).map(function () {
        var elm = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
        return elm.replace(/\r?\n|\r/g, ' ').trim().replace(/<[^>]*>/g, function (str) {
          return str.replace(/\s/g, '');
        }).split(/\s+/);
      })).map(function (elm) {
        if (elm.charAt(0) !== '<') {
          elm = '<' + elm;
        }
        if (elm.charAt(elm.length - 1) !== '>') {
          elm = elm + '>';
        }
        return elm;
      });

      return value.join(' ').trim();

    default:
      return (0, _emailjsMimeCodec.mimeWordsEncode)((value || '').toString().replace(/\r?\n|\r/g, ' '), 'B');
  }
}
function encodeHeaderValue ( key ) { var value = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : '' ; key = normalizeHeaderKey ( key ) ; switch ( key ) { case 'From' : case 'Sender' : case 'To' : case 'Cc' : case 'Bcc' : case 'Reply-To' : return convertAddresses ( parseAddresses ( value ) ) ; case 'Message-Id' : case 'In-Reply-To' : case 'Content-Id' : value = value . replace ( / \r?\n|\r / g , ' ' ) ; if ( value . charAt ( 0 ) !== '<' ) { value = '<' + value ; } if ( value . charAt ( value . length - 1 ) !== '>' ) { value = value + '>' ; } return value ; case 'References' : value = [ ] . concat . apply ( [ ] , [ ] . concat ( value ) . map ( function ( ) { var elm = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : '' ; return elm . replace ( / \r?\n|\r / g , ' ' ) . trim ( ) . replace ( / <[^>]*> / g , function ( str ) { return str . replace ( / \s / g , '' ) ; } ) . split ( / \s+ / ) ; } ) ) . map ( function ( elm ) { if ( elm . charAt ( 0 ) !== '<' ) { elm = '<' + elm ; } if ( elm . charAt ( elm . length - 1 ) !== '>' ) { elm = elm + '>' ; } return elm ; } ) ; return value . join ( ' ' ) . trim ( ) ; default : return ( 0 , _emailjsMimeCodec . mimeWordsEncode ) ( ( value || '' ) . toString ( ) . replace ( / \r?\n|\r / g , ' ' ) , 'B' ) ; } }
Encodes a header value for use in the generated rfc2822 email.

@param {String} key Header key
@param {String} value Header value
Encodes a header value for use in the generated rfc2822 email .