From 78b0731457d4f810261ffa128c1a1aaa7d3b3b3b Mon Sep 17 00:00:00 2001 From: vista Date: Sat, 18 Mar 2023 01:31:30 +0100 Subject: [PATCH 1/7] Update 'README.md' --- README.md | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c87b1b0..009665a 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,65 @@ # msmtp -send mail from your container \ No newline at end of file +send mail from your container +this image is intended to be used in a CI piple + + +## Environment variables + +| Variable Name | Requered | Description | Example +|--------------------|-----|------------------|-------- +|`SMTP_HOST` | Yes | The smtp url of your email server | `smtp.gmail.com` +|`SMTP_PORT` | no | The smtp port usually `25`, `465` or `587` *this is the default* | `587` +|`SMTP_FROM` | Yes | Your email address | `my_email@gmail.com` +|`SMTP_USER` | Yes | Your username for the server
usually the same as your email addres or the part before the @ | `my_email` +|`SMTP_PASSWORD` | Yes | its where the password go's
*the password gets stored in plaintext on the container* | `Hunter22` +|`EMAIL` | No | The "raw" email | Example [here](###-the-second-way) +|`TO_ADDRESSES` | Yes | The adress or addresses to send to
to send to multiple addresses add `, ` (comma and space) betean each address | `alice@outlook.com, bob@gamil.com` +|`SUBJECT` | No | The email subject | `text` +|`MESSAGE` | No | The body off the email | `lots of text` +|`SMTP_AUTH` | No | enable/disable authentication
Valid values are `off` or `on` *this is the default* | `on` +|`SMTP_TLS` | No | enable/disable TLS encryption
Valid values are `off` or `on` *this is the default* | `on` + +### Environment variables files +it is also posable subsitute the variables [above](##-Environment-variables) with a file +to use this simpy take what you normaly use for the variable and put it in a file +and make the contents of the `_FILE` variable the path to that file +using this way other proccesses could provide the email content +all of these are optinal but when uses the overwrite the counterpart variable +| Variable Name | Description | +|--------------------|-------------| +|`MSMTP_CONFIG_FILE` | This is the config file msmtp uses
this replaces the need for most other Environment variables
When you use this only `EMAIL` or `TO_ADDRESSES`, `SUBJECT`, `MESSAGE` are requered
to see what the file sould contain have a look at the [Documentation](https://marlam.de/msmtp/msmtp.html#Configuration-files) or a [Example](https://marlam.de/msmtp/msmtprc.txt) +|`SMTP_HOST_FILE` | +|`SMTP_PORT_FILE` | +|`SMTP_FROM_FILE` | +|`SMTP_USER_FILE` | +|`SMTP_PASSWORD_FILE`| +|`EMAIL_FILE` | + +## Writing the email + +There a 2 ways to write the actual email +### the first way +provide the `TO_ADDRESSES` and `SUBJECT` and `MESSAGE` environment variables +this is a very basic and simple way to write the email + +### the second way +provide the `EMAIL` environment variable +this is a more advanced way to write the email +using the `EMAIL` overwrites the `TO_ADDRESSES` and `SUBJECT` and `MESSAGE` environment variables +a basic `EMAIL` is formated like below +``` +To: recipient@gmail.com +Subject: The subject (followd by a empty line) + +This is the first like of the body +``` + +## Defaults for popular mail servers +if its not on the list figger it out yourself *and make a pull request* +tip: search for your servers imap clent settings usually it also lists smtp settings +| Name | `SMTP_HOST` | `SMTP_PORT` | +|---------|-------------------------|-------------| +| Gmail | `smtp.gmail.com` | `587` | +| Outlook | `smtp-mail.outlook.com` | `587` | +| Yahoo | `smtp.mail.yahoo.com` | `587` | -- 2.49.1 From e05a7d01b02ca32a9eb628672603443dbc82bf08 Mon Sep 17 00:00:00 2001 From: vista Date: Sat, 18 Mar 2023 01:34:39 +0100 Subject: [PATCH 2/7] Update 'README.md' --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 009665a..eaee232 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ this image is intended to be used in a CI piple |`SMTP_FROM` | Yes | Your email address | `my_email@gmail.com` |`SMTP_USER` | Yes | Your username for the server
usually the same as your email addres or the part before the @ | `my_email` |`SMTP_PASSWORD` | Yes | its where the password go's
*the password gets stored in plaintext on the container* | `Hunter22` -|`EMAIL` | No | The "raw" email | Example [here](###-the-second-way) +|`EMAIL` | No | The "raw" email | Example [here](#the-second-way) |`TO_ADDRESSES` | Yes | The adress or addresses to send to
to send to multiple addresses add `, ` (comma and space) betean each address | `alice@outlook.com, bob@gamil.com` |`SUBJECT` | No | The email subject | `text` |`MESSAGE` | No | The body off the email | `lots of text` @@ -21,7 +21,7 @@ this image is intended to be used in a CI piple |`SMTP_TLS` | No | enable/disable TLS encryption
Valid values are `off` or `on` *this is the default* | `on` ### Environment variables files -it is also posable subsitute the variables [above](##-Environment-variables) with a file +it is also posable subsitute the variables [above](#environment-variables) with a file to use this simpy take what you normaly use for the variable and put it in a file and make the contents of the `_FILE` variable the path to that file using this way other proccesses could provide the email content -- 2.49.1 From 306dec1d455cee135e78eb5c483e0833ed9a150d Mon Sep 17 00:00:00 2001 From: vista Date: Sat, 18 Mar 2023 01:35:50 +0100 Subject: [PATCH 3/7] dev (#1) Reviewed-on: https://git.narvas.tech/vista/msmtp/pulls/1 --- build/start-container.sh | 57 ++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 11 deletions(-) diff --git a/build/start-container.sh b/build/start-container.sh index 81c6271..3877c2c 100644 --- a/build/start-container.sh +++ b/build/start-container.sh @@ -1,15 +1,50 @@ #! /usr/bin/env sh -echo "defaults -auth on -tls on +if [ -n "${SMTP_HOST_FILE}" ]; then + SMTP_HOST=$cat ${SMTP_HOST_FILE}); +fi -account default -host ${SMTP_HOST} -port ${SMTP_PORT} -tls_starttls ${SMTP_STARTTLS} -from ${SMTP_FROM} -user ${SMTP_USER} -password ${SMTP_PASSWORD}" > ~/.msmtprc +if [ -n "${SMTP_PORT_FILE}" ]; then + SMTP_PORT=$(cat ${SMTP_PORT_FILE}); +fi -echo -e "Subject: ${SUBJECT}\n\n${MESSAGE}" | msmtp ${TO_ADDRESS} \ No newline at end of file +if [ -n "${SMTP_FROM_FILE}" ]; then + SMTP_FROM=$(cat ${SMTP_FROM_FILE}); +fi + +if [ -n "${SMTP_USER_FILE}" ]; then + SMTP_USER=$(cat ${SMTP_USER_FILE}); +fi + +if [ -n "${SMTP_PASSWORD_FILE}" ]; then + SMTP_PASSWORD=$(cat ${SMTP_PASSWORD_FILE}); +fi + +IFS= + +if [ -n "${EMAIL_FILE}" ]; then + EMAIL=$(cat ${EMAIL_FILE}); +else + if [ -z "${EMAIL}" ]; then + EMAIL="To: ${TO_ADDRESSES}\nSubject: ${SUBJECT}\n\n${MESSAGE}"; + fi +fi + +if [ -z "${MSMTP_CONFIG_FILE}" ]; then + MSMTP_CONFIG_FILE=~/.msmtprc + touch ${MSMTP_CONFIG_FILE} + chmod 600 ${MSMTP_CONFIG_FILE} + echo "defaults + auth ${SMTP_AUTH:-on} + tls ${SMTP_TLS:-on} + + account default + host ${SMTP_HOST} + port ${SMTP_PORT:-587} + tls_starttls ${SMTP_STARTTLS:-on} + from ${SMTP_FROM} + user ${SMTP_USER} + password ${SMTP_PASSWORD}" > ${MSMTP_CONFIG_FILE} +fi + +echo -e "${EMAIL}" | msmtp --read-recipients -C ${MSMTP_CONFIG_FILE} \ No newline at end of file -- 2.49.1 From 552715382d29f2d9a4be3874d4ae34da27dee072 Mon Sep 17 00:00:00 2001 From: vista Date: Sat, 18 Mar 2023 01:44:35 +0100 Subject: [PATCH 4/7] Update 'README.md' --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eaee232..df1a48b 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ using this way other proccesses could provide the email content all of these are optinal but when uses the overwrite the counterpart variable | Variable Name | Description | |--------------------|-------------| -|`MSMTP_CONFIG_FILE` | This is the config file msmtp uses
this replaces the need for most other Environment variables
When you use this only `EMAIL` or `TO_ADDRESSES`, `SUBJECT`, `MESSAGE` are requered
to see what the file sould contain have a look at the [Documentation](https://marlam.de/msmtp/msmtp.html#Configuration-files) or a [Example](https://marlam.de/msmtp/msmtprc.txt) +|`MSMTP_CONFIG_FILE` | This is the config file msmtp uses
this replaces the need for most other Environment variables
When you use this only `EMAIL` or `TO_ADDRESSES`, `SUBJECT`, `MESSAGE` are requered
to see what the file sould contain have a look at the [Documentation](https://marlam.de/msmtp/msmtp.html#Configuration-files) or a [Example](https://marlam.de/msmtp/msmtprc.txt)
the file **MUST** have [permissions](https://linuxcommand.org/lc3_lts0090.php) set to 600 |`SMTP_HOST_FILE` | |`SMTP_PORT_FILE` | |`SMTP_FROM_FILE` | -- 2.49.1 From a478e58aa96540470c062c768753bd8aea498c58 Mon Sep 17 00:00:00 2001 From: vista Date: Sat, 18 Mar 2023 01:53:48 +0100 Subject: [PATCH 5/7] Update 'README.md' --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index df1a48b..f18b68a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # msmtp +[![status-badge](https://woodpecker.narvas.tech/api/badges/vista/msmtp/status.svg)](https://woodpecker.narvas.tech/vista/msmtp) send mail from your container this image is intended to be used in a CI piple -- 2.49.1 From 06e0833b75b179056b221a138a4a164dfa9c700c Mon Sep 17 00:00:00 2001 From: vista Date: Sat, 18 Mar 2023 01:54:50 +0100 Subject: [PATCH 6/7] Update '.woodpecker/build.yml' [SKIP CI] --- .woodpecker/build.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.woodpecker/build.yml b/.woodpecker/build.yml index 91a2908..39dbae4 100644 --- a/.woodpecker/build.yml +++ b/.woodpecker/build.yml @@ -1,5 +1,9 @@ when: branch: master + event: [push, tag, deployment, cron, manual] + cron: nightly + path: + include: [ '.woodpecker/build.yml', 'build/*', 'Dockerfile' ] pipeline: check_base: @@ -23,8 +27,3 @@ pipeline: context: ./build repo: vistanarvas/${CI_REPO_NAME} auto_tag: true - when: - path: - include: [ '.woodpecker/build.yml', 'build/*', 'Dockerfile' ] - cron: nightly - event: [push, tag, deployment, cron, manual] -- 2.49.1 From 700629a8f9688784c1f33be3ee7bdf6a05b5675e Mon Sep 17 00:00:00 2001 From: vista Date: Sat, 18 Mar 2023 01:55:20 +0100 Subject: [PATCH 7/7] Update '.woodpecker/build-dev.yml' --- .woodpecker/build-dev.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.woodpecker/build-dev.yml b/.woodpecker/build-dev.yml index 0386310..7b140b5 100644 --- a/.woodpecker/build-dev.yml +++ b/.woodpecker/build-dev.yml @@ -1,5 +1,8 @@ when: branch: dev + event: [push, manual] + path: + include: [ '.woodpecker/build-dev.yaml', 'build/*', 'Dockerfile' ] pipeline: build_and_publish: @@ -11,7 +14,3 @@ pipeline: context: ./build repo: vistanarvas/${CI_REPO_NAME} tag: dev - when: - path: - include: [ '.woodpecker/build-dev.yaml', 'build/*', 'Dockerfile' ] - event: [push, manual] -- 2.49.1