Giter Club home page Giter Club logo

mailrise's Introduction

My bio

Just a guy who hangs out in userspace, with interests in homelab operations and video game development. You'll find me playing with a high-level language like Python or TypeScript.

Have a coding, consulting, or modding job? Drop me a mail!

Projects I have authored or contributed to

Homelab

  • Mailrise - Software defined SMTP server that emits notifications powered by Apprise.
  • Apprise - Migration to Python 3. Native asyncio support.
  • DsDDNS - A dynamic DNS client with native support for IPv6.

Other notable

  • Otto - A Discord bot for aviation nerds written in F#.
  • Don't kill my app! - Research on the DuraSpeed system app killer for Nokia devices.

Gaming

Gaming / Train Simulator Classic

  • Open NEC - Replacement scripts for Northeast Corridor content with a focus on realistic safety systems.
  • TypeScriptToLua - Support for Lua 5.0, the dialect used by Train Simulator.
  • railworks-tstl-template - Write type safe scripts for Train Simulator with TypeScriptToLua.
  • RailSimRemote - Use the RailDriver API over HTTP to read and manipulate control states.

Gaming / Open Rails

IRL

  • Getting you to work, courteously and efficiently. ๐ŸšŒ

mailrise's People

Contributors

adrydale avatar brian9206 avatar dependabot[bot] avatar yoryan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mailrise's Issues

Container crashes / won't start: "No module named 'mailrise'"

Hi there, and thanks for this great project BTW.

I'm having a strange issue that I've never seen before (not that experienced in the container business).
Container appears to start on startup with the following log output:

2023-03-03 18:07:48.899607+00:00 File "/home/mailrise/.local/bin/mailrise", line 5, in <module>
2023-03-03 18:07:48.899628+00:00 from mailrise.skeleton import run
2023-03-03 18:07:48.899638+00:00 ModuleNotFoundError: No module named 'mailrise'

Followed the docs, mounted a config file, tried latest and stable variants.
Not sure if I'm missing something here, sounds python, not container related though, any ideas?

SMTP `AUTH LOGIN` no response after inputting the username and password

Hi there,

My MailRise instance is not providing any response after authenticating. Usually it would provide a response code of 235 if the authentication was successful. Or 535 response code if the authentication data was incorrect. But my instance does not provide any response after entering the base64 encoded username and password. I'm not exactly sure if this is a bug with the MailRise software or an issue with my configuration.

DEMO

root@shell-demo:/# telnet [domain_name] 587
Trying 10.42.1.22...
Connected to [domain_name].
Escape character is '^]'.
220 [domain_name] Mailrise 1.3.0
EHLO [domain_name]
250-[domain_name]
250-SIZE 33554432
250-8BITMIME
250-SMTPUTF8
250-AUTH LOGIN PLAIN
250 HELP
AUTH LOGIN
334 VXNlciBOYW1lAA==
dXNlcm5hbWUK
334 UGFzc3dvcmQA
cGFzc3dvcmQK
[No Response]

LOGS

/home/mailrise/.local/lib/python3.11/site-packages/aiosmtpd/smtp.py:372: UserWarning: Requiring AUTH while not requiring TLS can lead to security vulnerabilities!
  warn("Requiring AUTH while not requiring TLS "
[2024-01-18 20:34:55] WARNING:mail.log:auth_required == True but auth_require_tls == False
[2024-01-18 20:40:16] WARNING:mail.log:auth_required == True but auth_require_tls == False

mailrise.conf

mailrise.conf: |
    configs:
      basic_assistant:
        urls:
          - hasio://HOST/ACCESS_TOKEN
    # figure out how to map roles directly to user email address
    #import_code: /script/router.py
    listen:
      port: 587
    tls:
      mode: "off"
      #mode: starttls
      #certfile: /etc/ssl/tls.crt
      #keyfile: /etc/ssl/tls.key
    smtp:
      auth:
        basic:
          username: password
      hostname: [domain_name]

For your reference, I am using MailRise 1.3.0 in a Kubernetes container. I've also tried it on the stable edition and I am getting the same issue. I tried it on the latest edition and it seems to be getting a different bug found in issue #98. Could you check if this is a bug with the software?

Thank you,

Andre S.

Catch all config option and wildcard options

Hi,

Is it possible to add the ability for mailrise to forward notifications without specifying specific addresses?
Eg. I was thinking a catch-all such as:

configs:
  *:
    urls:
      - signal://example.com:8080/+1234567890

And/Or a wildcard option for a domain like:

configs:
  *@example.com:
    urls:
      - signal://example.com:8080/+1234567890

Just something I thought would be useful for my use case where I am the only user and using mailrise to forward any/all notifications from local services. Not sure if this has other implications which make this a bad idea.

Publish images to GHCR

Dockerhub has a rate limit of 100 pulls/6 hours and is continuing to make decisions that aren't on the best interest to FOSS. It would be great if you could push the docker image to GHCR as well. It should only be a few extra lines in your workflow file. Thanks!

Error 450 while sending emails(Docker)

While i was configured Mailrise, i tried testing my notification setup by testing with multiple programs that send email. It seems that it receive the error 450 from the client and the log in docker shows. I am sending emails to [email protected] to the correct host.

 WARNING:apprise:Failed to load Apprise configuration from memory://

Using yoryan/mailrise:latest docker image on an amd64 machine, and latest dockerr release, debian buster

here is my mailrise.conf

configs:
  alerts:
    urls:
     discord://(REDACTED)/(REDACTED)

and here's the verbose logs

[2021-08-23 15:40:12] INFO:mailrise.skeleton:Loaded configuration with 1 recipient(s),
[2021-08-23 15:40:12] INFO:mail.log:Available AUTH mechanisms: LOGIN(builtin) PLAIN(builtin),
[2021-08-23 15:40:12] INFO:mail.log:Peer: ('::1', 40312, 0, 0),
[2021-08-23 15:40:12] INFO:mail.log:('::1', 40312, 0, 0) handling connection,
[2021-08-23 15:40:12] INFO:mail.log:('::1', 40312, 0, 0) EOF received,
[2021-08-23 15:40:12] INFO:mail.log:('::1', 40312, 0, 0) Connection lost during _handle_client(),
[2021-08-23 15:40:12] INFO:mail.log:('::1', 40312, 0, 0) connection lost,
[2021-08-23 15:40:13] INFO:mail.log:Available AUTH mechanisms: LOGIN(builtin) PLAIN(builtin),
[2021-08-23 15:40:13] INFO:mail.log:Peer: ('REDACTED IP', 38840),
[2021-08-23 15:40:13] INFO:mail.log:('REDACTED IP', 38840) handling connection,
[2021-08-23 15:40:13] INFO:mail.log:('REDACTED IP', 38840) >> b'EHLO [127.0.0.1]',
[2021-08-23 15:40:13] INFO:mail.log:('REDACTED IP', 38840) >> b'MAIL FROM:<[email protected]>',
[2021-08-23 15:40:13] INFO:mail.log:('REDACTED IP', 38840) sender: [email protected],
[2021-08-23 15:40:13] INFO:mail.log:('REDACTED IP', 38840) >> b'RCPT TO:<[email protected]>',
[2021-08-23 15:40:13] INFO:mailrise.skeleton:Accepted recipient: [email protected],
[2021-08-23 15:40:13] INFO:mail.log:('REDACTED IP', 38840) recip: [email protected],
[2021-08-23 15:40:13] INFO:mail.log:('REDACTED IP', 38840) >> b'DATA',
[2021-08-23 15:40:13] INFO:mailrise.skeleton:Accepted email, subject: My Smtp Alert (1) Testing,
[2021-08-23 15:40:13] WARNING:apprise:Failed to load Apprise configuration from memory://,
[2021-08-23 15:40:13] INFO:mail.log:('REDACTED IP', 38840) EOF received,
[2021-08-23 15:40:13] INFO:mail.log:('REDACTED IP', 38840) Connection lost during _handle_client(),
[2021-08-23 15:40:13] INFO:mail.log:('REDACTED IP', 38840) connection lost,

Dockerfile no longer builds - AttributeError: cython_sources

I started getting the error below in my pipeline 9 days ago which is also the day Python 3.12 was released. Bumping PyYAML to 6.0.1 in setup.cfg seems to resolve the issue.

Digest: sha256:5624c7648b31ecd8b03eef4b0805f3ecd8b9703a7caf2480c0d3beb2a09968b4
Status: Downloaded newer image for python:3
 ---> e5f0ac29ea7f
Step 2/16 : WORKDIR /code
 ---> Running in 4306a0a7a14e
Removing intermediate container 4306a0a7a14e
 ---> e03917533c36
Step 3/16 : COPY . .
 ---> 9142c9141354
Step 4/16 : RUN pip install --user --no-cache-dir --no-warn-script-location .
 ---> Running in 75a2cf22b1c8
Processing /code
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
  Preparing metadata (pyproject.toml): started
  Preparing metadata (pyproject.toml): finished with status 'done'
Collecting apprise==1.4.5 (from mailrise==1.4.0.post1.dev4+gf7543c3)
  Obtaining dependency information for apprise==1.4.5 from https://files.pythonhosted.org/packages/fe/3d/abff61b16fc4fd06e6d7be7c1645514447ab6e2950134f67d0cf7860def0/apprise-1.4.5-py3-none-any.whl.metadata
  Downloading apprise-1.4.5-py3-none-any.whl.metadata (41 kB)
     โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 41.5/41.5 kB 2.6 MB/s eta 0:00:00
Collecting aiosmtpd==1.4.4.post2 (from mailrise==1.4.0.post1.dev4+gf7543c3)
  Downloading aiosmtpd-1.4.4.post2-py3-none-any.whl (154 kB)
     โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 154.2/154.2 kB 9.9 MB/s eta 0:00:00
Collecting PyYAML==6.0 (from mailrise==1.4.0.post1.dev4+gf7543c3)
  Downloading PyYAML-6.0.tar.gz (124 kB)
     โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 125.0/125.0 kB 32.9 MB/s eta 0:00:00
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'error'
  error: subprocess-exited-with-error
  
  ร— Getting requirements to build wheel did not run successfully.
  โ”‚ exit code: 1
  โ•ฐโ”€> [54 lines of output]
      running egg_info
      writing lib/PyYAML.egg-info/PKG-INFO
      writing dependency_links to lib/PyYAML.egg-info/dependency_links.txt
      writing top-level names to lib/PyYAML.egg-info/top_level.txt
      Traceback (most recent call last):
        File "/usr/local/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/usr/local/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/usr/local/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-2yih6re6/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 355, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-2yih6re6/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 325, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-2yih6re6/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 341, in run_setup
          exec(code, locals())
        File "<string>", line 288, in <module>
        File "/tmp/pip-build-env-2yih6re6/overlay/lib/python3.12/site-packages/setuptools/__init__.py", line 103, in setup
          return distutils.core.setup(**attrs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-2yih6re6/overlay/lib/python3.12/site-packages/setuptools/_distutils/core.py", line 185, in setup
          return run_commands(dist)
                 ^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-2yih6re6/overlay/lib/python3.12/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
          dist.run_commands()
        File "/tmp/pip-build-env-2yih6re6/overlay/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
          self.run_command(cmd)
        File "/tmp/pip-build-env-2yih6re6/overlay/lib/python3.12/site-packages/setuptools/dist.py", line 989, in run_command
          super().run_command(command)
        File "/tmp/pip-build-env-2yih6re6/overlay/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/tmp/pip-build-env-2yih6re6/overlay/lib/python3.12/site-packages/setuptools/command/egg_info.py", line 318, in run
          self.find_sources()
        File "/tmp/pip-build-env-2yih6re6/overlay/lib/python3.12/site-packages/setuptools/command/egg_info.py", line 326, in find_sources
          mm.run()
        File "/tmp/pip-build-env-2yih6re6/overlay/lib/python3.12/site-packages/setuptools/command/egg_info.py", line 548, in run
          self.add_defaults()
        File "/tmp/pip-build-env-2yih6re6/overlay/lib/python3.12/site-packages/setuptools/command/egg_info.py", line 586, in add_defaults
          sdist.add_defaults(self)
        File "/tmp/pip-build-env-2yih6re6/overlay/lib/python3.12/site-packages/setuptools/command/sdist.py", line 113, in add_defaults
          super().add_defaults()
        File "/tmp/pip-build-env-2yih6re6/overlay/lib/python3.12/site-packages/setuptools/_distutils/command/sdist.py", line 251, in add_defaults
          self._add_defaults_ext()
        File "/tmp/pip-build-env-2yih6re6/overlay/lib/python3.12/site-packages/setuptools/_distutils/command/sdist.py", line 336, in _add_defaults_ext
          self.filelist.extend(build_ext.get_source_files())
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "<string>", line 204, in get_source_files
        File "/tmp/pip-build-env-2yih6re6/overlay/lib/python3.12/site-packages/setuptools/_distutils/cmd.py", line 107, in __getattr__
          raise AttributeError(attr)
      AttributeError: cython_sources
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

ร— Getting requirements to build wheel did not run successfully.
โ”‚ exit code: 1
โ•ฐโ”€> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
The command '/bin/sh -c pip install --user --no-cache-dir --no-warn-script-location .' returned a non-zero code: 1
exit status 1
๏ฟฝ[0m

Allow use of variables in urls

It would be nice to expand the use of template string variables in urls for a catch all config

for example:

configs:
  # gmail pass-through
  "*@gmail.com":
    urls:
      - mailtos://user:[email protected]?from=${from}&to=${to}
    mailrise:
      title_template: "${subject}"

essentially this enables mailrise the ability to easily pass-through email to an external smtp server with a catch all

my use case is for Ombi where the system may send notification to multiple users using mailrise but some user only has email configured and it would be tedious to have individual entry for each of those user.

Version 1.3.0

Verbose Logging

Is there anyway to increase the verbosity of logging? Would be nice to see which email address the failure occurred on. I have 20 or so setup.

Container logs

[2022-05-06 05:09:41] WARNING:apprise:Failed to send Gotify notification: Verification Failed., error=401.
[2022-05-06 05:09:45] WARNING:apprise:Failed to send Gotify notification: Verification Failed., error=401.
[2022-05-06 05:09:50] WARNING:apprise:Failed to send Gotify notification: Verification Failed., error=401.
[2022-05-06 05:09:51] WARNING:apprise:A Connection error occurred posting to Discord.
[2022-05-06 05:09:56] WARNING:apprise:A Connection error occurred posting to Discord.
[2022-05-06 05:10:02] WARNING:apprise:A Connection error occurred posting to Discord.
[2022-05-06 05:12:28] WARNING:apprise:A Connection error occurred posting to Discord.
[2022-05-06 05:12:28] WARNING:apprise:A Connection error occurred sending Email notification to smtp.gmail.com.
[2022-05-06 06:00:04] WARNING:apprise:Failed to send to Discord notification: Bad Request - Unsupported Parameters., error=400.
[2022-05-06 07:01:56] WARNING:apprise:Failed to send to Discord notification: Bad Request - Unsupported Parameters., error=400.
[2022-05-06 07:20:12] WARNING:apprise:Failed to send to Discord notification: Bad Request - Unsupported Parameters., error=400.
[2022-05-06 07:26:09] WARNING:apprise:Failed to send to Discord notification: Bad Request - Unsupported Parameters., error=400.
[2022-05-06 07:32:42] WARNING:apprise:Failed to send to Discord notification: Bad Request - Unsupported Parameters., error=400.
[2022-05-06 08:05:33] WARNING:apprise:Failed to send to Discord notification: Bad Request - Unsupported Parameters., error=400.
[2022-05-06 09:00:06] WARNING:apprise:Failed to send to Discord notification: Bad Request - Unsupported Parameters., error=400.
[2022-05-06 11:25:23] WARNING:apprise:Failed to send to Discord notification: Bad Request - Unsupported Parameters., error=400.
[2022-05-06 12:23:39] WARNING:apprise:Failed to send Gotify notification: Verification Failed., error=401.

SMTP Basic authentication not working?

My mailrise config is thus:

configs:
  # You can send to this config with "[email protected]".
  #
  telegram:
    urls:
      - tgram://<mytgramtoken>/mychatid/
    # You can also control the layout of the message with custom template
    # strings.
    # mailrise:
    #   title_template: "Urgent: ${body}"
    #   body_template: ""
    #   body_format: text
  pover:
    urls:
      - pover://<mypushoverid>
smtp:
  auth:
    basic:
      myusername:mypassword

As you can see, I have smtp auth specified above. However, the following command works, even when no authentication details are passed in.

sendemail -f [email protected] -t [email protected] -u "Test Email 2" -m "Hello World!" -s 192.168.x.x:8025

Any idea what's going on? How can I verify smtp authentication is working as expected?

Radha.

Feature request: Filtering the text in the body

I'm wanting to use Mailrise to forward email to Telegram, but the emails I'm forwarding are formatted with HTML. Apprise properly converts that HTML, but that HTML also includes styling so that while it looks fine when rendered in a browser, it isn't as nice without that styling. When that HTML (and styling) is removed, the email ends up with a lot of unnecessary content.

What I'm looking for to solve that is to take an email like this:

<html><h1>Here's an email!</h1><p>This is the real message!</p></html>

and apply a conversion such that we'd end up calling Apprise with something like:

apprise --body="This is the real message!"

HTML isn't regular but I think regex will likely enough for most use-cases since I imagine most people will only need to get a few lines of text from an email if they need to use it.

Something in the config like:

configs:
  "*@*":
    mailrise:
      body_pattern: '(?<=<p>).+?(?=<\/p>)'
    urls:
      - tgram://...

That regex means "see text starting with <p> but don't include it, get all text after it, see text ending with </p> but don't include it". So applying that pattern to the message, we'd get my desired "This is the real message!" as the body that is sent to Apprise.

Things I've considered:

  1. Putting this in Apprise instead.
    • Feels wrong since Apprise just wants to deal with content directly, not map it to some other format.
  2. Changing the email before it gets to Apprise.
    • Possible, by writing some sort of SMTP forwarder. I don't think such a thing currently exists but that's the approach I'll take if this is a poor fit for Mailrise.

Alternative approaches:

  • Instead of supplying a pattern, supplying a file that can be executed with the text of the email in its args and outputs the new text as output.
    • Seemed overly complicated but does allow the most flexibility.

It's been a while since I've written some Python, but if you think this is a useful feature, I don't mind writing it up myself. I recognize that body_pattern can be confusing when body_template already exists but I can't think of anything better.

Errors

Whenever I try to send a notification (tried with slack and pushover) I keep getting the following error:

[2022-06-08 23:48:09] WARNING:apprise:Failed to load Apprise configuration from memory://
[2022-06-08 23:48:09] ERROR:apprise:There are service(s) to notify
[2022-06-08 23:48:09] WARNING:mailrise.skeleton:Notification failed: Test Message โžค [email protected]

I tried sending an apprise notification and that works

apprise -vv -b 'my notification body' \
   'slack://xxxxx/xxxxxx/xxxxx'

How do I fix this?

aiosmtpd rejects unknown parameters in MAIL FROM

I am struggling to get one of my systems in my homelab to work. vCenter seems to be passing AUTH=<> as part of the message and mailrise is rejecting the email and returning it sender.

while talking to [IP address]:
MAIL From:[email protected] SIZE=1459 AUTH=<>
<<< 555 MAIL FROM parameters not recognized or not implemented
554 5.0.0 Service unavailable

Not sure if this is a bug or not

Error 400 - Sending to Discord

I am running the latest release for docker, and it just stopped working for Discord.

My config looks like this:

configs:
"@":
urls:
- discord://116282579146/zn0S_c_pMFh1o5U68yT7Msef_8TgXPCXEwpZ3oEf_ZMFJ54b8Uc

This is the same config I've been using for quite some time with no issues, yet now all the emails are getting rejected. The logs say:

2023-10-14T19:05:15.430152683Z [2023-10-14 12:05:15] WARNING:mailrise.skeleton:Notification failed: Postmaster Copy: Undelivered Mail โžค postmaster@
2023-10-14T19:05:15.544137022Z [2023-10-14 12:05:15] WARNING:mailrise.skeleton:Notification failed: Undelivered Mail Returned to Sender โžค webmin@
2023-10-14T19:05:26.990883518Z [2023-10-14 12:05:26] WARNING:mailrise.skeleton:Notification failed: Undelivered Mail Returned to Sender โžค root@
2023-10-14T19:05:28.231093925Z [2023-10-14 12:05:28] WARNING:apprise:Failed to send to Discord notification: Bad Request - Unsupported Parameters., error=400.
2023-10-14T19:05:28.232503392Z [2023-10-14 12:05:28] WARNING:mailrise.skeleton:Notification failed: Cron root@pve2 test -x /usr/sbin/anacron || { cd / && run-parts --report /etc/cron.daily; } โžค root@
2023-10-14T19:10:27.620136150Z [2023-10-14 12:10:27] WARNING:apprise:Failed to send to Discord notification: Bad Request - Unsupported Parameters., error=400.
2023-10-14T19:10:27.622009431Z [2023-10-14 12:10:27] WARNING:mailrise.skeleton:Notification failed: vzdump backup status (pve2.cotb.local.lan) : backup failed โžค
2023-10-14T19:10:33.244988612Z [2023-10-14 12:10:33] WARNING:mailrise.skeleton:Notification failed: Undelivered Mail Returned to Sender โžค

I've tried a new webhook, just to be sure there's no problem there, same issue.

Any ideas? Perhaps we need an update to the Discord library?

Thanks!

SMTP session exception - KeyError: 'multipart/related'

Great project, thanks for your work!

I'm experiencing an issue when I'm trying to use mailrise as an SMTP->Telegram gateway. I'd like mailrise to forward emails with attached images from my security cameras to a Telegram group conversation. I'm using Blue Iris as an NVR software and mailrise is running on the same machine as BI on windows x64 with Python 3.9.7.

configs:
  telegram:
    urls:
      - tgram://BOTID/CHATID/?image=Yes

When sending an email I'm experiencing the following error:

[2021-09-02 22:42:41] INFO:mailrise.skeleton:Loaded configuration with 1 recipient(s)
[2021-09-02 22:42:41] INFO:mail.log:Available AUTH mechanisms: LOGIN(builtin) PLAIN(builtin)
[2021-09-02 22:42:41] INFO:mail.log:Peer: ('::1', 62137, 0, 0)
[2021-09-02 22:42:41] INFO:mail.log:('::1', 62137, 0, 0) handling connection
[2021-09-02 22:42:41] INFO:mail.log:('::1', 62137, 0, 0) EOF received
[2021-09-02 22:42:41] INFO:mail.log:('::1', 62137, 0, 0) Connection lost during _handle_client()
[2021-09-02 22:42:41] INFO:mail.log:('::1', 62137, 0, 0) connection lost
[2021-09-02 22:42:46] INFO:mail.log:Available AUTH mechanisms: LOGIN(builtin) PLAIN(builtin)
[2021-09-02 22:42:46] INFO:mail.log:Peer: ('127.0.0.1', 62141)
[2021-09-02 22:42:46] INFO:mail.log:('127.0.0.1', 62141) handling connection
[2021-09-02 22:42:46] INFO:mail.log:('127.0.0.1', 62141) >> b'HELO nvr.local'
[2021-09-02 22:42:46] INFO:mail.log:('127.0.0.1', 62141) >> b'MAIL FROM:<blueiris@nvr>'
[2021-09-02 22:42:46] INFO:mail.log:('127.0.0.1', 62141) sender: blueiris@nvr
[2021-09-02 22:42:46] INFO:mail.log:('127.0.0.1', 62141) >> b'RCPT TO:<[email protected]>'
[2021-09-02 22:42:46] INFO:mailrise.skeleton:Accepted recipient: [email protected]
[2021-09-02 22:42:46] INFO:mail.log:('127.0.0.1', 62141) recip: [email protected]
[2021-09-02 22:42:46] INFO:mail.log:('127.0.0.1', 62141) >> b'DATA'
[2021-09-02 22:42:47] ERROR:mail.log:('127.0.0.1', 62141) SMTP session exception
Traceback (most recent call last):
  File "C:\Python39\lib\site-packages\aiosmtpd\smtp.py", line 728, in _handle_client
    await method(arg)
  File "C:\Python39\lib\site-packages\aiosmtpd\smtp.py", line 1438, in smtp_DATA
    status = await self._call_handler_hook('DATA')
  File "C:\Python39\lib\site-packages\aiosmtpd\smtp.py", line 465, in _call_handler_hook
    status = await hook(self, self.session, self.envelope, *args)
  File "C:\Python39\lib\site-packages\mailrise\smtp.py", line 113, in handle_DATA
    notification = parsemessage(message)
  File "C:\Python39\lib\site-packages\mailrise\smtp.py", line 200, in parsemessage
    body = body_part.get_content().strip()
  File "C:\Python39\lib\email\message.py", line 1096, in get_content
    return content_manager.get_content(self, *args, **kw)
  File "C:\Python39\lib\email\contentmanager.py", line 25, in get_content
    raise KeyError(content_type)
KeyError: 'multipart/related'
[2021-09-02 22:42:47] INFO:mail.log:('127.0.0.1', 62141) EOF received
[2021-09-02 22:42:47] INFO:mail.log:('127.0.0.1', 62141) Connection lost during _handle_client()
[2021-09-02 22:42:47] INFO:mail.log:('127.0.0.1', 62141) connection lost

Any help would be appreciated.

Feature Request- Configuration File example

Since I'm a relative noob to writing config files for docker containers it would be nice to have an example of /etc/mailrise.conf to work from. So I could cut down some different errors of syntax, etc... Thanks for making such a great project!

Specify log level via config

I'm trying to troubleshoot an issue where apprise is not happy with the contents of the message passed through from mailrise, so I'd like to see details of what's going on.

Mailrise is running via Portainer in a docker container using the published image. Config is specified in a docker compose file and has documented in /etc/mailrise.conf.

Is there a way to specify verbose logging as per #14 via an environment variable or in mailrise.conf ?

App issues

Hi!

I'm interested in having the mailrise app as a middleware for all applications and manage there all the accesses to other notification systems, but I'm encountering some issues. I have multiple questions about the app:

  • When using the wildcard "@" with sendgrid:// or mailto:// (mailtos://) connections the "${to}" field is not setup properly and thus cannot forward the email. Could you add the feature for the "${to}" variable to be used also in the "urls" config section? This would make the app much more dynamic
  • I have an email address for which I want to use a different notification connection, but the email has a dot "." in the string. How to add the full email (a workaround is to use the wildcard sign, but that might filter other emails too)?
  • Could you add a feature to relay / modify / template the email notification based on the source app sending the notification instead of the recipient? (usage: I don't want that all source apps send the same subject string)
  • The source email received in the mailrise app is most probably formatted in HTML and I didn't find any documentation that the relaying connection has to convert the input to the format "text" (using tgram:// I HAD to use "?format=text), if not there were errors in the app. Why don't you use by default the HTML type of source, thus eliminating the option to set the "mailrise.body_format: html" option in the config?

Additionally, you could add in the documentation for debugging purposes to use the following docker-compose command:
entrypoint: ["mailrise","-vv","/etc/mailrise.conf"]

Thanks for your answers!

Notification failed telegram

I've installed via docker mailrise, pointed OMV settings to mailrise, but i cant receive any notifications...

My config is

configs:
telegram:
urls:
tgram://token/-1chat
mailrise:
body_format: text

Docker logs

[2023-06-19 11:37:02] WARNING:apprise:Failed to load Apprise configuration from memory://
[2023-06-19 11:37:02] ERROR:apprise:There are no service(s) to notify
[2023-06-19 11:37:02] WARNING:mailrise.skeleton:Notification failed: [BURJUY-NAS.local] Test message from burjuy-nas โžค [email protected]

Allow environment variable configuration to be passed to configuration file

Hi ๐Ÿ‘‹๐Ÿผ it would be nice if the configuration file could read env vars, home assistant has a pretty neat way for this to work

docker compose

mailrise:
  image: yoryan/mailrise
  container_name: mailrise
  restart: unless-stopped
  env:
    DISCORD_WEBHOOK: discord://WEBHOOK_ID/WEBHOOK_TOKEN
  volumes:
    - ./mailrise.conf:/etc/mailrise.conf:ro

mailrise config

configs:
  telegram_and_discord:
    urls:
      - !env_var DISCORD_WEBHOOK

This feature is pretty handy when using an orchestration platform like Kubernetes where you can use secrets as environment variables.

Mailrise service fails to start

Here is the failure I'm getting:

โ— mailrise.service - Mailrise SMTP notification relay
Loaded: loaded (/etc/systemd/system/mailrise.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu 2023-03-30 11:32:49 CDT; 2min 5s ago
Process: 73661 ExecStart=/usr/local/bin/mailrise /etc/mailrise.conf (code=exited, status=1/FAILURE)
Main PID: 73661 (code=exited, status=1/FAILURE)

Mar 30 11:32:49 bde1.bluedragon.local systemd[1]: Started Mailrise SMTP notification relay.
Mar 30 11:32:49 bde1.bluedragon.local mailrise[73661]: Traceback (most recent call last):
Mar 30 11:32:49 bde1.bluedragon.local mailrise[73661]: File "/usr/local/bin/mailrise", line 7, in
Mar 30 11:32:49 bde1.bluedragon.local mailrise[73661]: from mailrise.skeleton import run
Mar 30 11:32:49 bde1.bluedragon.local mailrise[73661]: File "/usr/local/lib/python3.6/site-packages/mailrise/skeleton.py", line 5
Mar 30 11:32:49 bde1.bluedragon.local mailrise[73661]: from future import annotations
Mar 30 11:32:49 bde1.bluedragon.local mailrise[73661]: ^
Mar 30 11:32:49 bde1.bluedragon.local mailrise[73661]: SyntaxError: future feature annotations is not defined
Mar 30 11:32:49 bde1.bluedragon.local systemd[1]: mailrise.service: Main process exited, code=exited, status=1/FAILURE
Mar 30 11:32:49 bde1.bluedragon.local systemd[1]: mailrise.service: Failed with result 'exit-code'.

Unable to start docker container

I should have made some configuration mistake, but can't see where...
All i got is in my container is

24/11/2022 14:57:35 [2022-11-24 13:57:35] WARNING:mail.log:('10.0.0.210', 55783) unrecognised: GET
24/11/2022 14:57:35 [2022-11-24 13:57:35] WARNING:mail.log:('10.0.0.210', 55783) unrecognised: HOST:
24/11/2022 14:57:35 [2022-11-24 13:57:35] WARNING:mail.log:('10.0.0.210', 55783) unrecognised: USER-AGENT:
24/11/2022 14:57:35 [2022-11-24 13:57:35] WARNING:mail.log:('10.0.0.210', 55783) unrecognised: ACCEPT:
24/11/2022 14:57:35 [2022-11-24 13:57:35] WARNING:mail.log:('10.0.0.210', 55783) unrecognised: ACCEPT-LANGUAGE:
24/11/2022 14:57:35 [2022-11-24 13:57:35] WARNING:mail.log:('10.0.0.210', 55783) too many bogus commands

Here is my docker-compose :

mailrise:
  image: yoryan/mailrise:latest
  container_name: mailrise
  ports:
    - 8025:8025
  volumes:
    - /docker_data2/mailrise/config/mailrise.conf:/etc/mailrise.conf
  restart: unless-stopped
  labels:
    - "com.centurylinklabs.watchtower.enable=true"

and here is my config file :

configs:
  [email protected]:
    urls:
      - discord://REDACTED/REDACTED

Custom Discord Avatar with Alert

Is it possible to set a custom Discord Avatar to use with an alert?
I see that you can change the theme depending on if its a .info or .critical or whatever.
but what I was hoping to do is set like a path to a particular png or something to use when it calls the webhook. Is this possible?

Failed to send to Discord notification: Bad Request

I have 9 cron jobs setup that send an email to mailrise which in turns sends them to Gotify and Discord. All 9 work to Gotify. 2 of 9 work to Discord. Below is the error message I see in the logs, error=400.

Is this something within mailrise or is it something I need to log an issue with apprise?

[2022-05-14 09:00:05] WARNING:apprise:Failed to send to Discord notification: Bad Request - Unsupported Parameters., error=400.
[2022-05-14 09:00:05] WARNING:mailrise.skeleton:Notification failed: Cron <local@local4> bash /home/osuhickeys/Documents/Docker/gitea/gitea_backup.sh โžค [email protected]

How to use certificates without root user

This isn't so much an issue with mailrise as it is more of a question in how to get what I would assume is a common workflow working.

I would like to use tls with mailrise. Currently I have a caddy docker container configured to get certificates for any apps on my server. Caddy is very useful as it auto renews the certificates.

For other apps using tls I map the caddy volume containing the certificates to the app in question, it then can use the certs by specifying the filepath to them.

This doesn't work however for mailrise as the caddy certificates are owned by root and mailrise therefore cannot access them as it does not have permission.

I have tried to run mailrise as root, but it doesn't work as the files are installed under the mailrise user, caddy needs to run as root so it can access privileged ports. There also doesn't seem to be any option to change file ownership when mapping volumes in docker.

Just wondering if you have any suggestions or have come across this before?

Feature request - enable smtp auth

I would like to see a way to use some kind of authentication when you send emails to the mailrise. At least some type of local username/password list in the configuration file or maybe even a LDAP(S) integration if it can be implemented easily.

I know that this is meant to be used in a private network where there shouldn't be unauthorised access, but I still would want to use authentication.

How to use Traefik with TLS + Auth

Hi there,

had a great experience with mailrise so far! However, I am struggling by using Auth behind Traefik proxy (tls). I tried e.g. with Bitwarden but could not get it to work...

Tested e.g. also with swaks:

swaks --to [email protected] --server mailrise.example.com --protocol SMTPS --auth LOGIN --auth-user username                  
Password: password
=== Trying mailrise.example.com:465...
=== Connected to mailrise.example.com.
=== TLS started with cipher TLSv1.3:AEAD-CHACHA20-POLY1305-SHA256:256
=== TLS no local certificate set
=== TLS peer DN="/CN=TRAEFIK DEFAULT CERT"
<~  220 eb1dfe93fb00 Mailrise 0.0.post1.dev1+g79b73fd
 ~> HELO fancyhostname
<~  250 eb1dfe93fb00
*** Host did not advertise authentication
 ~> QUIT
<~  221 Bye
=== Connection closed with remote host.

Mailrise config:

configs:
  [email protected]
    urls:
      - signals://xxxxx


# Finally, you can enable TLS encryption and/or SMTP authentication if you
# want them.

# tls:
#   mode: starttls
#   certfile: /path/to/certificate.pem
#   keyfile: /path/to/privatekey.pem

#!env_var MAILRISE_PASSWORD
smtp:
  auth:
    basic:
      username: password

Mailrise logs:

[2023-04-09 17:39:33] WARNING:mail.log:auth_required == True but auth_require_tls == False
/home/mailrise/.local/lib/python3.11/site-packages/aiosmtpd/smtp.py:372: UserWarning: Requiring AUTH while not requiring TLS can lead to security vulnerabilities!
  warn("Requiring AUTH while not requiring TLS "
[2023-04-09 17:39:33] INFO:mail.log:Available AUTH mechanisms: LOGIN(builtin) PLAIN(builtin)
[2023-04-09 17:39:33] INFO:mail.log:Peer: ('192.168.XXX.XXX', 59120)
[2023-04-09 17:39:33] INFO:mail.log:('192.168.XXX.XXX', 59120) handling connection
[2023-04-09 17:39:33] DEBUG:mail.log:('192.168.XXX.XXX', 59120) << b'220 eb1dfe93fb00 Mailrise 0.0.post1.dev1+g79b73fd'
[2023-04-09 17:39:33] DEBUG:mail.log:_handle_client readline: b'HELO fancyhostname\r\n'
[2023-04-09 17:39:33] INFO:mail.log:('192.168.XXX.XXX', 59120) >> b'HELO fancyhostname
[2023-04-09 17:39:33] DEBUG:mail.log:('192.168.XXX.XXX', 59120) << b'250 eb1dfe93fb00'
[2023-04-09 17:39:33] DEBUG:mail.log:_handle_client readline: b'QUIT\r\n'
[2023-04-09 17:39:33] INFO:mail.log:('192.168.XXX.XXX', 59120) >> b'QUIT'
[2023-04-09 17:39:33] DEBUG:mail.log:('192.168.XXX.XXX', 59120) << b'221 Bye'
[2023-04-09 17:39:33] INFO:mail.log:('192.168.XXX.XXX', 59120) connection lost
[2023-04-09 17:39:33] INFO:mail.log:('192.168.XXX.XXX', 59120) Connection lost during _handle_client()

Is there something I miss here? Mailrise is configured in plaintext (without TLS), but connection from client to Traefik reverseproxy is done via TLS... So only traffic from traffic from Traefik to mailrise should be plaintext am I right? Is there a config flag to suppress the warning / does the fact, that mailrise itself is in "plaintext mode" cause problems with auth?

Bitwarden SMTP config:
image

Bitwarden error:
image

EDIT:
This seems to work:

curl -vvv smtps://mailrise.example.com -u username:password --ssl-reqd \
  --mail-from '[email protected]' --mail-rcpt '[email protected]' --upload-file mail.txt;
* Connected to mailrise.example.com (192.168.xxx.xxx) port 465 (#0)
*  CAfile: /etc/ssl/cert.pem
*  CApath: none
* (304) (OUT), TLS handshake, Client hello (1):
} [310 bytes data]
* (304) (IN), TLS handshake, Server hello (2):
{ [122 bytes data]
* (304) (IN), TLS handshake, Unknown (8):
{ [6 bytes data]
* (304) (IN), TLS handshake, Certificate (11):
{ [4301 bytes data]
* (304) (IN), TLS handshake, CERT verify (15):
{ [520 bytes data]
* (304) (IN), TLS handshake, Finished (20):
{ [36 bytes data]
* (304) (OUT), TLS handshake, Finished (20):
} [36 bytes data]
* SSL connection using TLSv1.3 / AEAD-CHACHA20-POLY1305-SHA256
* Server certificate:
*  subject: CN=example.com
*  start date: Feb 23 13:27:42 2023 GMT
*  expire date: May 24 13:27:41 2023 GMT
*  subjectAltName: host "mailrise.example.com" matched cert's "*.example.com"
*  issuer: C=US; O=Let's Encrypt; CN=R3
*  SSL certificate verify ok.
< 220 eb1dfe93fb00 Mailrise 0.0.post1.dev1+g79b73fd
> EHLO mail.txt
< 250-eb1dfe93fb00
< 250-SIZE 33554432
< 250-8BITMIME
< 250-SMTPUTF8
< 250-AUTH LOGIN PLAIN
< 250 HELP
> AUTH PLAIN
< 334 
> AHVzZXJuYW1lAHBhc3N3b3Jk
< 235 2.7.0 Authentication successful
> MAIL FROM:<[email protected]> SIZE=14
< 250 OK
> RCPT TO:<[email protected]>
< 250 OK
> DATA
< 354 End data with <CR><LF>.<CR><LF>
} [14 bytes data]

Am I doing something wrong in terms of configuration (bitwarden) or cli parameters (swaks)?
Would be nice, if you could me point to the right direction :).

Thank you!

Question - Preserving look and feel of notifications

Is it possible to preserve the look and feel of a notification so that it looks the same going to directly to Gotify and Discord? When I send them through mailrise, they do not look the same.

Application --> Mailrise -- Gotify
mailrise

Application directly to Gotify
gotify

Individual recipients based on emails usernames?

It is more of a team/corp usecase but nevertheless.
Let's assume we have a service, say redmine. And a chat app, say slack or matrix.
And users on all services have one-to-one username match (by internal policies or an SSO)
It would be great to send notifications to personal messages like [email protected] โ†’ [email protected]

As far as I can see by the docs there is no way right now to do this. Am I missing something?

If not, then can this be added somehow? As I can assume there will be needed to add a username template variable at minimum and deal with #49. And maybe some ability to invoke functions for transforms if there is something more complicated

No module named 'mailrise'

Hello, I got an issue where the log would tell me

Traceback (most recent call last):

  File "/home/mailrise/.local/bin/mailrise", line 5, in <module>

    from mailrise.skeleton import run

ModuleNotFoundError: No module named 'mailrise'

All I did was trying to run it from docker compose with the following docker-compose.yml

version: "3"

services:
  mailrise:
    image: yoryan/mailrise:latest
    ports:
      - 24:25
    user: "root"
    environment:
      - TZ="Europe/Berlin"
    restart: unless-stopped
    volumes:
      - /opt/mailrise/data/mailrise.conf:/etc/mailrise.conf:ro

my mailrise.conf looks like this even though I dont think it matters much in this case

configs:
  gotify:
    urls:
      - gotify://IP/Token

As you probably already guessed Im quite new to this so help would be great :)

TLS disables authentication

Config:

configs:
  pushover:
    urls:
      - pover://xxxxxxxxxxxxxxxx@yyyyyyyyyyyyyyyyy
tls:
  mode: starttls
  certfile: /etc/ssl/cert.pem
  keyfile: /etc/ssl/key.pem
smtp:
  hostname: nxdomain.info
  auth:
    basic:
      pushover: xxxxxxxxxxxxxxxxxxx

msmtp:

<-- 220 nxdomain.info Mailrise 0.0.post1.dev1+g8928d73
--> EHLO localhost
<-- 250-nxdomain.info
<-- 250-SIZE 33554432
<-- 250-8BITMIME
<-- 250-SMTPUTF8
<-- 250-STARTTLS
<-- 250 HELP
--> QUIT
<-- 221 Bye
msmtp: the server does not support authentication

Observation: 250-AUTH LOGIN PLAIN is missing

Log:

[2022-12-20 16:34:36] ERROR:asyncio:Fatal error: protocol.data_received() call failed.
protocol: <asyncio.sslproto.SSLProtocol object at 0x7f5392c1b710>
transport: <_SelectorSocketTransport fd=10 read=polling write=<idle, bufsize=0>>
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 1009, in _read_ready__data_received
    self._protocol.data_received(data)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'SSLProtocol' object has no attribute 'data_received'
[2022-12-20 16:34:36] ERROR:mail.log:('172.18.0.1', 37216) SMTP session exception
Traceback (most recent call last):
  File "/home/mailrise/.local/lib/python3.11/site-packages/aiosmtpd/smtp.py", line 895, in smtp_STARTTLS
    await waiter
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 1009, in _read_ready__data_received
    self._protocol.data_received(data)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'SSLProtocol' object has no attribute 'data_received'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/mailrise/.local/lib/python3.11/site-packages/aiosmtpd/smtp.py", line 728, in _handle_client
    await method(arg)
  File "/home/mailrise/.local/lib/python3.11/site-packages/aiosmtpd/smtp.py", line 899, in smtp_STARTTLS
    raise TLSSetupException() from error
aiosmtpd.smtp.TLSSetupException

Steps to reproduce:

I generated a self-signed certifcate, changed the owner to the mailrise container user and mounted it:

openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 3650 -nodes -subj '/CN=nxdomain.info'
sudo chown 999:999 *.pem
  mailrise:
    container_name: mailrise
    image: yoryan/mailrise
    restart: always
    volumes:
      - ./mailrise.conf:/etc/mailrise.conf
      - ./cert.pem:/etc/ssl/cert.pem
      - ./key.pem:/etc/ssl/key.pem

mailto doesn't work

I need help getting Mailrise to send emails through Gmail. I can get it to work for Apprise. I'm able to get Mailrise to work for other services like ntfy. I am using the Gmail app password like Apprise specifies.

configs:

  "*@*":
    urls:
      - mailto://myuser:[email protected]

tls:
  mode: off

Dockerfile build failing trying to use --use-feature=in-tree-build

I have mailrise setup as a CI/CD pipeline to rebuild daily and push an image to my local repo. It started failing 4 days ago with the error in the logs below. Looks like --use-feature=in-tree-build may have been deprecated from pip and now the options are 2020-resolver, fast-deps, or truststore???

CI/CD Pipeline Logs

Step 2/16 : WORKDIR /code
 ---> Running in 732845b7294f
Removing intermediate container 732845b7294f
 ---> 5d17f01b648c
Step 3/16 : COPY . .
 ---> c8d28783d2f6
Step 4/16 : RUN pip install --user --no-cache-dir --use-feature=in-tree-build --no-warn-script-location .
 ---> Running in fb5517e5cf76

Usage:   
  pip install [options] <requirement specifier> [package-index-options] ...
  pip install [options] -r <requirements file> [package-index-options] ...
  pip install [options] [-e] <vcs project url> ...
  pip install [options] [-e] <local project path> ...
  pip install [options] <archive url/path> ...

option --use-feature: invalid choice: 'in-tree-build' (choose from '2020-resolver', 'fast-deps', 'truststore')
The command '/bin/sh -c pip install --user --no-cache-dir --use-feature=in-tree-build --no-warn-script-location .' returned a non-zero code: 2
exit status 2

STARTTLS issue with aiosmtpd 1.4.2

I've been experiencing some issues with STARTTLS while using the latest Docker image (6415c43757780b5019dce526874a5acb03ad948013b175036bff909d7f5d555e)

Running with -vv gives the following output when trying to send a mail with STARTTLS set :

[2022-12-18 11:55:43] INFO:mailrise.skeleton:Loaded configuration with 2 recipient(s)
[2022-12-18 11:55:43] INFO:mailrise.skeleton:TLS enabled and successfully initialized
[2022-12-18 11:55:43] DEBUG:asyncio:Using selector: EpollSelector
[2022-12-18 11:55:43] INFO:mail.log:Available AUTH mechanisms: LOGIN(builtin) PLAIN(builtin)
[2022-12-18 11:55:43] INFO:mail.log:Peer: ('127.0.0.1', 48256)
[2022-12-18 11:55:43] INFO:mail.log:('127.0.0.1', 48256) handling connection
[2022-12-18 11:55:43] DEBUG:mail.log:('127.0.0.1', 48256) << b'220 87a5a7182b69 Mailrise 0.0.post1.dev1+gbf98187'
[2022-12-18 11:55:43] INFO:mail.log:('127.0.0.1', 48256) EOF received
[2022-12-18 11:55:43] DEBUG:asyncio:Using selector: EpollSelector
[2022-12-18 11:55:43] INFO:mail.log:('127.0.0.1', 48256) Connection lost during _handle_client()
[2022-12-18 11:55:43] INFO:mail.log:('127.0.0.1', 48256) connection lost
[2022-12-18 11:59:59] INFO:mail.log:Available AUTH mechanisms: LOGIN(builtin) PLAIN(builtin)
[2022-12-18 11:59:59] INFO:mail.log:Peer: ('192.168.1.2', 60942)
[2022-12-18 11:59:59] INFO:mail.log:('192.168.1.2', 60942) handling connection
[2022-12-18 11:59:59] DEBUG:mail.log:('192.168.1.2', 60942) << b'220 87a5a7182b69 Mailrise 0.0.post1.dev1+gbf98187'
[2022-12-18 11:59:59] DEBUG:mail.log:_handle_client readline: b'EHLO bascule\r\n'
[2022-12-18 11:59:59] INFO:mail.log:('192.168.1.2', 60942) >> b'EHLO bascule'
[2022-12-18 11:59:59] DEBUG:mail.log:('192.168.1.2', 60942) << b'250-87a5a7182b69'
[2022-12-18 11:59:59] DEBUG:mail.log:('192.168.1.2', 60942) << b'250-SIZE 33554432'
[2022-12-18 11:59:59] DEBUG:mail.log:('192.168.1.2', 60942) << b'250-8BITMIME'
[2022-12-18 11:59:59] DEBUG:mail.log:('192.168.1.2', 60942) << b'250-SMTPUTF8'
[2022-12-18 11:59:59] DEBUG:mail.log:('192.168.1.2', 60942) << b'250-STARTTLS'
[2022-12-18 11:59:59] DEBUG:mail.log:('192.168.1.2', 60942) << b'250 HELP'
[2022-12-18 11:59:59] DEBUG:mail.log:_handle_client readline: b'STARTTLS\r\n'
[2022-12-18 11:59:59] INFO:mail.log:('192.168.1.2', 60942) >> b'STARTTLS'
[2022-12-18 11:59:59] DEBUG:mail.log:('192.168.1.2', 60942) << b'220 Ready to start TLS'
[2022-12-18 11:59:59] ERROR:asyncio:Fatal error: protocol.data_received() call failed.
protocol: <asyncio.sslproto.SSLProtocol object at 0x7fdcfb0b6210>
transport: <_SelectorSocketTransport fd=10 read=polling write=<idle, bufsize=0>>
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 1001, in _read_ready__data_received
    self._protocol.data_received(data)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'SSLProtocol' object has no attribute 'data_received'
[2022-12-18 11:59:59] ERROR:mail.log:('192.168.1.2', 60942) SMTP session exception
Traceback (most recent call last):
  File "/home/mailrise/.local/lib/python3.11/site-packages/aiosmtpd/smtp.py", line 895, in smtp_STARTTLS
    await waiter
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 1001, in _read_ready__data_received
    self._protocol.data_received(data)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'SSLProtocol' object has no attribute 'data_received'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/mailrise/.local/lib/python3.11/site-packages/aiosmtpd/smtp.py", line 728, in _handle_client
    await method(arg)
  File "/home/mailrise/.local/lib/python3.11/site-packages/aiosmtpd/smtp.py", line 899, in smtp_STARTTLS
    raise TLSSetupException() from error
aiosmtpd.smtp.TLSSetupException
[2022-12-18 11:59:59] INFO:mail.log:('192.168.1.2', 60942) connection lost

I think this is related to this fix in aiosmtpd : aio-libs/aiosmtpd@827f232

If I edit setup.cfg and build my own Docker image with that specific commit :

install_requires =
    apprise==1.2.0
    #aiosmtpd==1.4.2
    aiosmtpd @ git+https://github.com/aio-libs/aiosmtpd.git@827f2321b7a926f3e8ba2aad6387b36c7c2e0b9a
    PyYAML==6.0

Then STARTTLS works as expected.

Looks like this fix will be in aiosmtpd 1.4.3, currently in rc. Just documenting this issue in case if get someone else ๐Ÿ‘

Filtering options

Hi,
really great project!

I have some applications which sends HTML encoded mails to mailrise.
Sadly matrix is not able to output the content correct. So I get some random gibbish in the notification.

Would it be possible to only pass through the subject of the mail? Most of the informations are in there so
it's okay when i don't get the body of the message. I think this solution is way easier then removing the HTML content.

ntfy attachments don't work

Hello.

I'm trying to send an attachment to ntfy through mailrise. I'm using mailsend:

mailsend -smtp mailrise.xyz -t [email protected] -attach "/var/log/system.log" -sub "System log" -f [email protected] -M "Here's the system log:"

However, the delivery fails:

[2024-01-26 17:33:01] WARNING:mailrise.skeleton:Notification failed: address: [ [email protected] โžค [email protected] ] subject: [ System log ] body: [ Here's the system (0.0K) ] attach: [ system.log (1536.8K) ]

If I remove the attachment, everything works as expected. AFAIK, Apprise supports attachments in ntfy notifications. What could be wrong? Thanks for any help.

Unable to get container working

Hey all. I am at a loss here. Trying to get mailrise working in a container with traefik and cannot for the life of me figure it out.
The container reports as running but has 0 logs when I run docker logs mailrise
I tried looking in the container but dont see any place that would define a log file or anything internally.
When I try to send a test email from for example gitea to mailrise.my.domain:465 gitea just hangs and nothing ever comes through. I have provided my configs below if anyone can offer assistance please.

If I have missed a file or something that would be useful for troubleshooting please let me know. I love the concept of this app and want to get it working and will do whatever needed to help that process happen.

Docker-compose.yml

networks:
  proxy:
    external: true

services:
  mailrise:
    image: yoryan/mailrise
    container_name: mailrise
    restart: unless-stopped
    networks:
      - proxy
    volumes:
      - /mnt/docker/mailrise/mailrise.conf:/etc/mailrise.conf:ro
    labels:
      traefik.tcp.routers.mailrise.rule: "HostSNI(`*`)"
      traefik.tcp.routers.mailrise.tls: "true"
      traefik.tcp.routers.mailrise.certresolver: "cloudflare"
      traefik.tcp.routers.mailrise.tls.domains[0].main: "mailrise.my.domain"
      traefik.tcp.routers.mailrise.tls.domains[0].sans: ""
      traefik.tcp.routers.mailrise.entrypoints: "mailsecure"
      traefik.docker.network: "proxy"

mailrise.conf

configs:

  crowdsec:
    urls:
      - discord://ID/key    
   

  gitea:
    urls:
      - discord://ID/KEY


smtp:
  auth:
    basic:
      username: password
      AzureDiamond: hunter2

traefik.yml

...
entryPoints:
  http:
    address: ":80"
    http:
      middlewares:
        - crowdsec-bouncer@file
      redirections:
        entryPoint:
          to: https
          scheme: https
  https:
    address: ":443"
  mailsecure:
    address: ":465"
...
certificatesResolvers:
  cloudflare:
    acme:
      email: myemail 
      storage: acme.json
      dnsChallenge:
        provider: cloudflare
        resolvers:
          - "1.1.1.1:53"
          - "1.0.0.1:53"
...

ghcr.io image cannot be pulled by version

When trying to pull the Docker image from ghcr.io, I get the following error.

โฏ docker pull ghcr.io/yoryan/mailrise:1.3.0
1.3.0: Pulling from yoryan/mailrise
manifest unknown

Apprise Update to Version 1.4.5

Hello,
is it possible to update apprise within the docker image to the latest apprise version (1.4.5)? This version came out recently, see also the corresponding pull request (build(deps): bump apprise from 1.3.0 to 1.4.5 #76 ).
Thanks.

Slack custom icon

Hi,

First of all, thank you for the excellent project!

Question: Is there a way to customize the slack icon for the notifications received? It would be great to be able to set custom icons (via image URL or otherwise) to more easily identify the systems that sent the notifications

Thank you!

Advertise auth support in EHLO

I'm basically hitting the problem described here:

https://marlam.de/msmtp/old-mailinglist/msg00533.html

I've configured mailrise to use basic authentication but msmtp fails to send mails.

EHLO as reported by msmtp -v:

<-- 220 a4360929b762 Mailrise 0.0.post1.dev1+gbf98187
--> EHLO localhost
<-- 250-a4360929b762
<-- 250-SIZE 33554432
<-- 250-8BITMIME
<-- 250-SMTPUTF8
<-- 250 HELP
--> QUIT
<-- 221 Bye
msmtp: the server does not support authentication
msmtp: could not send mail (account mailrise from /etc/msmtprc)

According to the msmtp devs the mailserver should report this as part of its EHLO.

Btw the Readme is a bit confusing. The example seems to be missing the auth key.

Readme:

smtp:
  basic:
    username: password
    AzureDiamond: hunter2

Correct config according to https://github.com/YoRyan/mailrise#configuration

smtp:
  auth:
    basic:
      username: password

Can't Parse URL with hyphen in domain name.

I'm not sure if this is a mailrise issue or an apprise issue but I'm running the mailrise docker. Actual URL and token have been changed below:

mailrise config:

"[email protected]":
urls:
- gotifys://gotify.first-last.net/2349sSDJfjk3jk21d

Docker Log:
[2023-11-19 21:41:35] ERROR:apprise:Unparseable Gotify URL gotify://gotify.first-last.net:2349sSDJfjk3jk21d
[2023-11-19 21:41:35] WARNING:apprise:Unparseable URL gotify://gotify.first-last.net:2349sSDJfjk3jk21d, entry #1
[2023-11-19 21:41:35] WARNING:apprise:Failed to load Apprise configuration from memory://
[2023-11-19 21:41:35] ERROR:apprise:There are no service(s) to notify
[2023-11-19 21:41:35] WARNING:mailrise.skeleton:Notification failed: address: [ [no sender] โžค [email protected] ] subject: [ Test Subject ] body: [ This is a test (0.0K) ]
[2023-11-19 21:46:27] WARNING:apprise:No message body or attachment was specified.
[2023-11-19 21:46:27] WARNING:mailrise.skeleton:Notification failed: address: [ "Test Sender" โžค [email protected] ] subject: [ Test Subject ] body: [ (0.0K) ]
[2023-11-19 21:47:11] WARNING:mail.log:('192.168.0.116', 63711) unrecognised: SSH-2.0-PUTTY_RELEASE_0.76
[2023-11-19 21:48:10] WARNING:apprise:Failed to send Gotify notification: Verification Failed., error=401.
[2023-11-19 21:48:10] WARNING:mailrise.skeleton:Notification failed: address: [ [no sender] โžค [email protected] ] subject: [ [no subject] ] body: [ Testing (0.0K) ]

I am able to use discord and pushover notifcations from the same mailrise docker. Only the gotify fails. I don't use the hyphenated URL for discord or pushover.

Cannot start mailrise docker container

I cant get this running after upgrade to latest version, tried to revert back to old version but can't get it work there either.
Tried everything i'll think. what am i doing wrong?

mailrise.conf file i'm using look like this

configs:
discord:
urls:
- discord://2308599788026707641/sdfnsdsdslkslsfalsfsdrlfsdulfsf

docker-compose running

version: '3.8'
services:
mailrise:
image: yoryan/mailrise:latest
container_name: mailrise
ports:
- 8025:8025
volumes:
- ./mailrise/mailrise.conf:/etc/mailrise.conf
restart: unless-stopped

Logged problem

Traceback (most recent call last):

File "/home/mailrise/.local/bin/mailrise", line 8, in

sys.exit(run())

         ^^^^^

File "/home/mailrise/.local/lib/python3.12/site-packages/mailrise/skeleton.py", line 171, in run

main(sys.argv[1:])

File "/home/mailrise/.local/lib/python3.12/site-packages/mailrise/skeleton.py", line 162, in main

controller.begin()

File "/home/mailrise/.local/lib/python3.12/site-packages/aiosmtpd/controller.py", line 370, in begin

srv: AsyncServer = self.loop.run_until_complete(self.server_coro)

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/local/lib/python3.12/asyncio/base_events.py", line 664, in run_until_complete

return future.result()

       ^^^^^^^^^^^^^^^

File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1505, in create_server

infos = await tasks.gather(*fs)

        ^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1437, in _create_server_getaddrinfo

infos = await self._ensure_resolved((host, port), family=family,

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1433, in _ensure_resolved

return await loop.getaddrinfo(host, port, family=family, type=type,

       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/local/lib/python3.12/asyncio/base_events.py", line 878, in getaddrinfo

return await self.run_in_executor(

             ^^^^^^^^^^^^^^^^^^^^^

File "/usr/local/lib/python3.12/asyncio/base_events.py", line 840, in run_in_executor

executor.submit(func, *args), loop=self)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 179, in submit

self._adjust_thread_count()

File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 202, in _adjust_thread_count

t.start()

File "/usr/local/lib/python3.12/threading.py", line 971, in start

_start_new_thread(self._bootstrap, ())

RuntimeError: can't start new thread

Can not get docker to start

Hello!

I can not get the docker image to run. I'm getting this error in the log:

/usr/local/bin/python: error while loading shared libraries: libpython3.11.so.1.0: cannot open shared object file: No such file or directory

Is there something I'm doing wrong?

TLS with traefik not working

First of all, thanks for this awesome tool.

I have been playing with it, and so far, it has been great.

Non TLS mode works like a charm.

I was able to make the TLS mode work with the onconnect mode and static cert and key files.

I tried the traefik approach but I couldn't make it work.
I am able to stabilish connection on port 465 on traefik, but it does not seem to redirect to mailrise.

I am wondering if there is anything I am missing on the config file.

This is what I have used:

configs:
telegram:
urls:
- tgram://123333:3333/-33444

smtp:
auth:
basic:
user: pass

Could you please let me know if I am missing something here?

Thank You!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.