Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/eldoy/mxmail

Send mail directly to mail exchange servers or SMTP.
https://github.com/eldoy/mxmail

Last synced: 6 days ago
JSON representation

Send mail directly to mail exchange servers or SMTP.

Awesome Lists containing this project

README

        

# Mxmail

Send email from the command line or your app.

### Installation

```
npm i mxmail
```

### Usage

```js
const mxmail = require('mxmail')

// If config is defined, mx lookup is skipped
const config = {
host: 'smtp.ethereal.email',
port: 587,
auth: {
user: '[email protected]',
pass: '1md9Xes49Nbfka6aFw'
}
}
const mailer = mxmail(config)

// Set up mail
const mail = {
from: '"Fred Foo 👻" ',
to: '[email protected], [email protected]',
subject: 'Hello ✔',
text: 'Are you ready?',
html: 'Are you ready?'
}

// Will lookup mx records automatically for each email in 'to'
const result = await mailer(mail)
```

### Command line

Install the command line interface with:
```
npm i -g mxmail
```

Add a settings file in ~/.mxmail.json:
```json
{
"from": "[email protected]",
"config": {
"host": "smtp.ethereal.email",
"port": 587,
"auth": {
"user": "[email protected]",
"pass": "1md9Xes49Nbfka6aFw"
}
},
"aliases": {
"@sp": "[email protected]"
}
}
```

Send email like this from the command line (terminal):
```
mx [email protected] subject "This is the message"
```

Replace with aliases like this:
```
mx @sp subject "This is the message"
```

Send file attachments like this:
```
mx @ve "File" "Check this" ~/file.jpg
```

Using zsh alias:
```
alias file='mx @ve "" ""'
file ~/file.jpg
```

MIT Licensed. Enjoy!