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.
- Host: GitHub
- URL: https://github.com/macrat/new-year-sender
- Owner: macrat
- License: mit
- Created: 2017-12-29T08:41:11.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-12-30T12:13:16.000Z (over 2 years ago)
- Last Synced: 2024-06-19T17:57:42.670Z (about 2 years ago)
- Language: Go
- Homepage:
- Size: 23.4 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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
```