https://github.com/bkeepers/mailmerge
https://github.com/bkeepers/mailmerge
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/bkeepers/mailmerge
- Owner: bkeepers
- License: mit
- Created: 2017-04-12T06:58:28.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-12T19:13:18.000Z (about 9 years ago)
- Last Synced: 2025-12-26T10:48:00.353Z (6 months ago)
- Language: Ruby
- Size: 7.81 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Mailmerge
A bare-bones mailmerge script.
## How it works
The mailmerge combines a CSV file of email addresses and associated data, with a TEXT file containing
the subject and body of an email.
It uses the headers of the CSV file to replace placeholders in the email template.
Take a look at test.csv (the data) and test.txt (the email template) for an example.
**Required fields**
The CSV file must have a header named `email`, which contains the email addresses used to dispatch
the emails.
## Setup
Install the dependencies using bundler.
```
bundle install
```
Create a .env file, and define the SMTP settings:
```
cp env.example .env
# edit .env
```
That can be whatever SMTP settings you have. Sendgrid, Mailgun, Gmail, etc.
If you want to send email from your Gmail account, you can set up an application-specific password, in
https://security.google.com/settings/security/apppasswords
```
SMTP_LOGIN=
SMTP_PASSWORD=
SMTP_PORT=587
SMTP_SERVER=smtp.gmail.net
```
## Sending Emails
Send emails with the following command:
```
CSV=foo.csv TEMPLATE=bar.txt ./mailmerge
```
If you don't pass the CSV and TEMPLATE arguments, then the script will use the defaults:
```
CSV=test.csv
TEMPLATE=test.txt
```
### Email Template
The first line of the template file is used for the subject line.
The rest of the file is used as the body of the email.
Each header can be referenced in the email template using the header name,
enclosed in double curly-braces (e.g. `{{username}}`).
See `test.txt` for an example.