Created
October 27, 2023 17:17
-
-
Save mgodf89/16156cc9ef8eb76d682420fe27885237 to your computer and use it in GitHub Desktop.
A Dockerfile for sending gmail messages from the command line!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:latest | |
# NOTE: Don't use your real password. Get an App Password from here: | |
# https://myaccount.google.com/apppasswords | |
# To Build: | |
# `docker build --build-arg email=<GMAIL_ADDRESS> --build-arg password=<GMAIL_PASSWORD> -t ssmtp .` | |
# To Run: | |
# `docker run -e MSG="Some Message" -e TO_EMAIL="recipient@example.com" ssmtp:latest` | |
ARG GMAIL_ADDRESS | |
ARG GMAIL_PASSWORD | |
RUN apt-get update | |
RUN apt-get install -y ssmtp | |
RUN touch /etc/ssmtp/ssmtp.conf | |
RUN echo "root=${GMAIL_ADDRESS}" >> /etc/ssmtp/ssmtp.conf | |
RUN echo "mailhub=smtp.gmail.com:465" >> /etc/ssmtp/ssmtp.conf | |
RUN echo "FromLineOverride=YES" >> /etc/ssmtp/ssmtp.conf | |
RUN echo "AuthUser=${GMAIL_ADDRESS}" >> /etc/ssmtp/ssmtp.conf | |
RUN echo "AuthPass=${GMAIL_PASSWORD}" >> /etc/ssmtp/ssmtp.conf | |
RUN echo "UseTLS=YES" >> /etc/ssmtp/ssmtp.conf | |
RUN useradd -ms /bin/bash email_user | |
USER email_user | |
CMD echo ${MSG} | ssmtp ${TO_EMAIL} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment