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

https://github.com/macrat/new-year-sender

The email sender for my new year email.
https://github.com/macrat/new-year-sender

Last synced: 12 months ago
JSON representation

The email sender for my new year email.

Awesome Lists containing this project

README

          

new-year-sender
===============

The email sender for new year email.

## Simple usage
Install new-year-sender,

``` shell
$ go get github.com/macrat/new-year-sender
```

Make source file like this,

``` yaml
apikey: your-API-key-of-SendGrid

from: your name

to:
- name

date: 2018-01-01 00:00 # the date to send email.

title: E-Mail subject

text: |
contents of an email.

this is test

html: |

contents of an email.

this is test

attach:
- path/to/file.ext
```

And send it.

``` shell
$ new-year-sender --source source-file.yml
```

## Send many emails
You can send many emails with the simple source file.
This behavior is like an object-based programming.

for example:

``` yaml
apikey: your-API-key-of-SendGrid

# common settings
from: your name

date: 2018-01-01 00:00

title: hello

text: |
hello!
this is test e-mail!!

attach:
- attached-file.png

# personal settings
mails:
- title: hello alice # override title
to:
- alice

- attach: # append attach
- attached-file2.png

to:
- bob@example.com

# more extend
- date: 2018-01-01 10:00

mails:
- to:
- charie@example.com
- dave@example.com
cc:
- charie2@example.com

- to:
- eve
```

This source will send 4 emails.

If you want test source, please use `--test` or `--dryrun` option.
`--test` option will validate source and display errors if that exists.
`--dryrun` option will execute `--test` and display parsed results.
Won't send emails if enabled either option.

Print like this when given the above source file with `--dryrun` option.

``` shell
$ new-year-sender --test < test.yml
title: hello alice
from: your name
to: ["alice" ]
cc: []
bcc: []
date: 2018-01-01 00:00:00 +0900 JST
Attached: attached-file.png

hello!
this is test e-mail!!

==============================
title: hello
from: your name
to: []
cc: []
bcc: []
date: 2018-01-01 00:00:00 +0900 JST
Attached: attached-file2.png, attached-file.png

hello!
this is test e-mail!!

==============================
title: hello
from: your name
to: [, ]
cc: []
bcc: []
date: 2018-01-01 10:00:00 +0900 JST
Attached: attached-file.png

hello!
this is test e-mail!!

==============================
title: hello
from: your name
to: ["eve" ]
cc: []
bcc: []
date: 2018-01-01 10:00:00 +0900 JST
Attached: attached-file.png

hello!
this is test e-mail!!
```

## Apply templates
Sender supports template for text and HTML body.

for example:

``` yaml
apikey: your-API-key-of-SendGrid

title: Template example

from: your name

text_template: |
Hello!

{{.Text}}

Best regards,

html_template: |

Hello!


{{.Html}}

Best regards,


mails:
- to: [alice ]
text:
How are you alice?
html:

How are you alice?

- to: [bob ]
text:
booooooooob
html:

booooooob


```