Skip to content

MinaMatta98/Bulk-Email-Cli-CLient

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust Build

Test

GitHub version

Bulk Email Cli Client

An asynchronous RUST based CLI bulk emailing client, built on top of lettre-rs.

Features

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


Instructions:

Installation:

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


Setting Environmental Variables


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


Send a Single Email


Refer to Environmental Variables for setting up environmental variables.

Scenario 1

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"

Scenario 2

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"

Scenario 3

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

Result




Send Bulk Emails


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"


Template Variable Substitution


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 Email
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

Single Email Substitution Example

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

Bulk Email Substitution Example

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"

About

An asynchronous RUST based CLI bulk emailing client, built on top of lettre-rs.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published