Launch Week Day 2: Introducing Reports: An Extensible Reporting Framework for Socket Data.Learn More
Socket
Book a DemoSign in
Socket

@evokegroup/mime

Package Overview
Dependencies
Maintainers
4
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@evokegroup/mime

```javascript import { MimeMessage } from '@evokegroup/mime';

latest
Source
npmnpm
Version
2.0.5
Version published
Maintainers
4
Created
Source

@evokegroup/mime

import { MimeMessage } from '@evokegroup/mime';

const message = new MimeMessage();
message.from = { address: 'first.last@domain.com', name: 'First Last' };
message.subject = 'This is an example';
message.to.add('user@domain.com');
message.to.add({ address: 'someone.else@domain.com', name: 'Someone Else' });
message.setHTML('<html><head><title>Email</title></head><body>Hello World!</body>');
message.unsubscribe.mailto('unsubscribe@domain.com');
message.unsubscribe.post('https://domain.com/unsubscribe?id=1');

// Using the constructor
const message = new MimeMessage({
  from: { address: 'first.last@domain.com', name: 'First Last' },
  subject: 'This is an example',
  to: ['user@domain.com', { address: 'someone.else@domain.com', name: 'Someone Else' }],
  content: '<html><head><title>Email</title></head><body>Hello World!</body>',
  headers: {
    'List-Unsubscribe': '<https://domain.com/unsubscribe?id=1>, <mailto:unsubscribe@domain.com>',
    'List-Unsubscribe-Post': 'List-Unsubscribe=One-Click'
  }
});

// ----
console.log(message.toString());

// Results
/*
From: "First Last" <first.last@domain.com>
To: user@domain.com, "Someone Else" <someone.else@domain.com>
Subject: This is an example
List-Unsubscribe: <https://domain.com/unsubscribe?id=1>, <mailto:unsubscribe@domain.com>
List-Unsubscribe-Post: List-Unsubscribe=One-Click
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: base64

PGh0bWw+PGhlYWQ+PHRpdGxlPkVtYWlsPC90aXRsZT48L2hlYWQ+PGJvZHk+SGVsbG8gV29ybGQhPC9ib2R5Pg==
*/

IMailAddress

NameType
addressstring
[name]string

MailAddress

NameType
addressstring
namestring

MailAddressList

NameType
listMailAddress[]
lengthnumber

add()

ParameterTypeDefaultDescription
addressstring ¦ IMailAddress ¦ MailAddress

remove()

ParameterTypeDefaultDescription
addressstring ¦ IMailAddress ¦ MailAddress

clear()

forEach()

ParameterTypeDefaultDescription
callbackFnfunction(element: MailAddress, index: number, array: MailAddress[])

map()

ParameterTypeDefaultDescription
callbackFnfunction(element: MailAddress)

IHeaderUnsubscribeMailto

NameType
addressstring
[subject]string

IHeaderUnsubscribePost

NameType
urlstring
[payload]string

HeaderUnsubscribe

NameType
liststring[]
lengthnumber

mailto

ParameterTypeDefaultDescription
addressstring, IHeaderUnsubscribeMailto
[subject]string

post

ParameterTypeDefaultDescription
urlstring, IHeaderUnsubscribePost
[payload]string

IAlternativePart

NameType
contentstring
[contentType]string
[charset]string
[contentTransferEncoding]string

AlternativePart

NameType
contentstring
[contentType]string
[charset]string
[contentTransferEncoding]string

constructor()

NameTypeDefaultDescription
contentstring
contentTypestringtext/html
charsetstringutf-8
contentTransferEncodingstringbase64

IMimeMessage

NameType
[from]string ¦ IMailAddress ¦ MailAddress
[replyTo]string ¦ IMailAddress ¦ MailAddress
[sender]string ¦ IMailAddress ¦ MailAddress
[to](string ¦ IMailAddress ¦ MailAddress)[]
[cc](string ¦ IMailAddress ¦ MailAddress)[]
[bcc](string ¦ IMailAddress ¦ MailAddress)[]
[subject]string
[alternatives]IAlternativePart[] ¦ AlternativePart[]
[headers]Record<string, string>

MimeMessage

NameType
fromstring ¦ IMailAddress ¦ MailAddress
replyTostring ¦ IMailAddress ¦ MailAddress
senderstring ¦ IMailAddress ¦ MailAddress
toMailAddressList
ccMailAddressList
bccMailAddressList
subjectstring
alternativesAlternativePart[]
unsubscribeHeaderUnsubscribe

setHeader()

NameTypeDefaultDescription
namestring
valuestring

setHTML()

NameTypeDefaultDescription
contentstring
charsetstringutf-8
contentTransferEncodingstringbase64

setText()

NameTypeDefaultDescription
contentstring
charsetstringutf-8
contentTransferEncodingstringbase64

toString()

Renders the MIME message.

ParameterTypeDefaultDescription
forceMultipartAlternativebooleanfalseForce the use of multipart/alternative content type when only 1 alternative has been added

FAQs

Package last updated on 22 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts