An asynchronous RUST based CLI bulk emailing client, built on top of lettre-rs.
Feature | Description |
---|---|
Template Variable Substitution | Refer to the Template Variable Substitution section for modifying email-templates |
Single Email Support | Refer to Send a Single Email |
Bulk Email Support | Support for asynchronous unordered sending of bulk emails detailed within a csv file as described within Send Bulk Emails |
Attachment Support | Support for Inline/Standard Attachments |
SMTP Transport | This tool uses the SMTP protocol to send emails over the network |
TLS Encryption | This tool defaults to TLS encryption over network |
Installation of this tool will require RUST installation version of 1.70 or newer.
To install this package via cargo, run the following command from a shell of choice:
cargo install --locked --git https://github.com/MinaMatta98/Bulk-Email-Cli-CLient.git
The following environmental variables must be set:
Variable | Description |
---|---|
SENDER_EMAIL | Email of the email account sending the Email(s) |
SENDER_PASSWORD | Corrosponding password for the email account sending Email(s).Turn on Less-Secure-Apps to send emails: https://myaccount.google.com |
SMTP_RELAY | The SMTP relay corrosponding to the SMTP Gateway of Choice. For example, Gmail uses smtp.gmail.com and AOL uses smtp.aol.com |
Refer to Environmental Variables for setting up environmental variables.
Send an email to minamatta98@gmail.com
with the template saved within ./templates/email.html
relative to the current working directory (check with bash pwd
).
email-sender single-email --to-addr "minamatta98@gmail.com" --subject "Email Testing CLI" --email-template "./templates/email.html"
Send an email to minamatta98@gmail.com
with the template saved within ./templates/email.html
relative to the current working directory (check with bash pwd
).
This is to also send a pdf attachment within the example directory relative to the root directory of this repository.
email-sender single-email --to-addr "minamatta98@gmail.com" --subject "Email Testing CLI" --email-template "./templates/email.html" attachments --attachment-1-path "./example/rust.pdf"
Send an email to minamatta98@gmail.com
with the template saved within ./templates/email.html
relative to the current working directory (check with bash pwd
).
This is to also send an inline email attachment located within ./example/send_mail_7590.png
corresponding to an inline content id of 2335.
email-sender single-email --to-addr "minamatta98@gmail.com" --subject "Email Testing CLI" --email-template "./templates/email.html" attachments --attachment-1-path "./example/send-mail-7590.svg" --attachment-1-inline-content-id 2335
All three scenarios are listed within their respective order within the following table.
This will correspond to the following csv file:
Note that unfilled fields must still be comma separated. Also note that attachment and substitution headers can be omitted where not needed
DeliveryAddress,Subject,RelativeEmailTemplatePath,Attachment1Path,Attachment1InlineContentId
minamatta98@gmail.com,Email Template Tests,./templates/email.html,,
deran_lockon@hotmail.com,Email Template Tests,./templates/email.html,./example/rust.pdf,
minamatta98@gmail.com,Email Template Tests,./templates/email.html,./example/send_mail_7590.png,2335
To send bulk emails from a csv file saved within ./example/example.csv
, run the following command from your shell of choice:
email-sender bulk-email --csv-file "./example/example.csv"
The following variables can be used within an email-template and encoded as {{field name}}
to be replaced:
Field Name | Description | Csv Header |
---|---|---|
name |
Replace instance of {{name}} within email-template to --name value |
Name |
email |
Replace instance of {{email}} within email-template to --email value |
|
date |
Replace instance of {{date}} within email-template to --date value |
Date |
time |
Replace instance of {{time}} within email-template to --time value |
Time |
order_number |
Replace instance of {{order_number}} within email-template to --order-number value |
OrderNumber |
product_information |
Replace instance of {{product_information}} within email-template to --product-information value |
ProductInformation |
location |
Replace instance of {{location}} within email-template to --location value |
Location |
username |
Replace instance of {{user_name}} within email-template to --user-name value |
Username |
confirmation_link |
Replace instance of {{confirmation_link}} within email-template to --confirmation-link value |
ConfirmationLink |
password_reset_link |
Replace instance of {{password_reset_link}} within email-template to --password-reset-link value |
PasswordResetLink |
discount_code |
Replace instance of {{discount_code}} within email-template to --discount-code value |
DiscountCode |
temp_code |
Replace instance of {{temp_code}} within email-template to --temp-code value |
TempCode |
course_details |
Replace instance of {{course_details}} within email-template to --course-details value |
CourseDetails |
In this example, instances of {{name}}
within the email-template will be replaced with Mina and instances of {{temp_code}}
will be replaced with 123456
cargo run --release -- single-email --to-addr "minamatta98@gmail.com" --subject "Email Testing CLI" --email-template "./templates/test.html" attachments --attachment-1-path "./example/send-mail-7590.svg" --attachment-1-inline-content-id 2335 token --name "Mina" --temp-code 123456
The following example accomplishes the same function as the single email substitution example.
Note that variables are evaluated separately for each row entry and can be left blank if not needed. Also note that field names for substitutions can be left empty if not needed. For example, the Name and TempCode header are not required if values are not passed.
Take this as an example email file saved within ./path/to/file.csv
:
DeliveryAddress,Subject,RelativeEmailTemplatePath,Attachment1Path,Attachment1InlineContentId,Name,TempCode
minamatta98@gmail.com,Email Template Tests,./templates/replacement_test.html,./example/send_mail_7590.png,2335,Mina,123456
Run the following cli command from the shell:
email-sender bulk-email --csv-file "./path/to/file.csv"