Compose emails from a a template file and a customers csv file. Output to a directory and invalid customers to a error csv file
./send_email
-customers string
(required) path to customers csv file
-error string
(required) path to errors csv file
-out string
(required) path to output emails directory
-template string
(required) path to email template json file
requires go v1.19+
- Build source into file
./send_email
go build -o ./send_email cmd/send_email/main.go- Run it, can use the provided test data in
etc/test/
./send_email -customers etc/test/customers.csv -out etc/test/out -template etc/test/email_template.json -error etc/test/errors.csv- Check the result in
etc/test/outandetc/test/errors.csv
Remember to point to a different error file each running time
- Build image and name it
email_sender
docker build -t email_sender .-
Prepare a folder that contains your
customers.csv,email_template.json,outdirectory, error fileerrors.csv. We can use theetc/testfolder as an example -
Run docker with mount directory
etc/test. Remember to remove theetc/test/errors.csvfile if any.
docker run -v /$(pwd)/etc/test/:/app/test/ email_sender_v1 ./send_email -customers test/customers.csv \
-out test/out/ \
-template test/email_template.json \
-error test/errors.csv- Check result in
outanderrors.csv
make test
==> Running tests...
ok github.com/ziggy192/email_sender 0.513s coverage: 71.0% of statementsmake fmtmake lint