https://github.com/eldoy/mxmail
Send mail directly to mail exchange servers or SMTP.
https://github.com/eldoy/mxmail
Last synced: about 1 year ago
JSON representation
Send mail directly to mail exchange servers or SMTP.
- Host: GitHub
- URL: https://github.com/eldoy/mxmail
- Owner: eldoy
- License: mit
- Created: 2021-04-12T19:18:54.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-10T12:18:49.000Z (over 3 years ago)
- Last Synced: 2025-04-12T18:46:36.150Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 257 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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: 'virginia.cassin10@ethereal.email',
pass: '1md9Xes49Nbfka6aFw'
}
}
const mailer = mxmail(config)
// Set up mail
const mail = {
from: '"Fred Foo 👻" ',
to: 'bar@example.com, baz@example.com',
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": "vidar@example.com",
"config": {
"host": "smtp.ethereal.email",
"port": 587,
"auth": {
"user": "virginia.cassin10@ethereal.email",
"pass": "1md9Xes49Nbfka6aFw"
}
},
"aliases": {
"@sp": "suong@example.com"
}
}
```
Send email like this from the command line (terminal):
```
mx suong@example.com 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!