Mutt is a powerful and highly configurable command-line email client for Unix-like systems. It supports various email protocols such as IMAP, POP3, and SMTP. Mutt is often used for reading and sending emails directly from the terminal, making it a popular choice for users who prefer command-line interfaces or need to automate email sending in scripts.
To send an email with Tmail Action, you need to generate password from you google account and add other Environments as github secrets. Also you need to specify various options such as the subject, recipients, body and attachments.
Note: Tmail currently only supports sending emails via Gmail's SMTP server. To use Gmail for sending emails, you need to generate an App Password from your Google account.
- Go to your Google Account.
- Navigate to Security.
- Under "Signing in to Google", select App passwords.
- You may need to sign in again to verify your identity.
- Choose Mail as the app and Other for the device. Enter a name for the password, then click Generate.
- Copy the generated app password and use it as
SMTP_PASS
in your environment variables.
For detailed instructions, you can also refer to this Gmail SMTP password generation tutorial.
This script demonstrates how an email is sent by using Tmail Action:
- Fetching Configuration Details: The script retrieves email configuration details from environment variables.
- Configuring
.muttrc
: It sets up the.muttrc
configuration file with the provided email settings, including sender details and SMTP server configuration. - Composing the Email: It constructs the
mutt
command to send the email with optional CC and attachments. - Sending the Email: Depending on the provided options, the script sends the email with either the body content directly or from a file, and attaches files if specified.
Variable | Description | Example |
---|---|---|
FROM_EMAIL |
Email address from which the email will be sent. | [email protected] |
FROM_NAME |
Name that will appear as the sender. | Sender Name |
SMTP_URL |
URL of the SMTP server used to send the email. | smtp://<youremail>@smtp.gmail.com:587/ |
SMTP_PASS |
Password for the SMTP server. | Password_Generated_from_google_account |
Variable | Description | Example |
---|---|---|
TO_EMAIL |
Email address of the recipient. | [email protected] |
SUBJECT |
Subject of the email. | Subject Subject |
MAIL |
Body content of the email (optional). | Email Body. |
CC |
Email address for CC (optional). | [email protected] |
EMAIL_FILE |
Path to a file containing the email body (optional). | /path/to/email_body.txt |
ATTACHMENT |
Path to a file to be attached to the email (optional). | /path/to/attachment.txt |
Set Environment Variables: Ensure the required environment variables are set. For security, sensitive information like FROM_EMAIL
, FROM_NAME
, SMTP_URL
, and SMTP_PASS
should be added as secrets in you Github repository.
- name: Tmail
uses: namgaytobden/Tmail@master
with:
#Github Secrets
fromEmail: ${{ secrets.FROM_EMAIL }}
fromName: ${{ secrets.FROM_NAME }}
smtpUrl: ${{ secrets.SMTP_URL }}
smtpPass: ${{ secrets.SMTP_PASS }}
#User Input
toEmail: '[email protected]'
subject: 'Your subject here'
attachment: 'path/to/your/file'
cc: '[email protected]'
mail: |
Your email body