Coder Social home page Coder Social logo

hascheksolutions / opentrashmail Goto Github PK

View Code? Open in Web Editor NEW
596.0 8.0 49.0 2.56 MB

Open Source standalone trashmail solution that ships its own mail server

License: Apache License 2.0

Python 8.67% PHP 87.26% CSS 1.32% HTML 0.42% JavaScript 0.15% Dockerfile 0.85% Shell 1.33%
trashmail selfhosted docker python php email-as-rss email-as-api

opentrashmail's People

Contributors

adamklaff avatar dan-q avatar eocommunity avatar geek-at avatar greyhatsec-au avatar lars- avatar manfromafar avatar marceltransier avatar mattburchett avatar mlocher avatar pbrln avatar poblabs avatar ranjit-git avatar tctlrd avatar wr3nch0x1 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

opentrashmail's Issues

Admin logs page

Would it be possible to make the logs/accounts list only accessible by the admin, possibly something similar to the site password but for these specific pages instead of the whole site.

Could also make it such that if the user is "logged in" with the admin password the home page shows all emails instead of needing to open a specific address

API returns "invalid email address" for every email address

Change 935d11a wraps strtolower($_REQUEST['email']) in basename(realpath(...)), which is important for preventing path traversal attacks... but breaks much of the functionality.

Making this change means that the $email variable contains a path, not an email address, and so subsequent calls to filter_var($email, FILTER_VALIDATE_EMAIL) always return false. Therefore, the API does not work.

Suggested change: perform all email filtering at the top, before running basename/realpath, and return the error only if (a) an email request parameter is passed and (b) the filter returns false. Then just use and trust the $email variable in the attachment, load, and list methods.

Open relay

When using this, bots are using the mailserver to send out SPAM.

Are there any way you could tell the mailserver, only to accept outgoing connections from localhost?

Is it possible to import old mail after a migration?

I've been messing with migrating the install and found that after I move the install to a new server opentrashmail fails to load previous emails.
It will only display emails up to the point in which it started receiving new emails.

So if it possible to tell opentrashmail to list old emails that are still on disk in the data dir?

custom settings per address

Settings should be overwritable per address.

So i can set cleanup time for a few hours but only on one addres, etc.

Also opens possibilities for configuring forwarding emails to different (real) mailboxes on a per-address basis

Consider using moment.js for date formatting

I'm in the US, and the date format opentrashmail is using doesn't make sense to me at first glance since we use Month/Day/Year format.

moment.js would be great for this type of date formatting to allow others to use the format they're used to.

This could be a quick add by using an option inside config.ini to define the string format, then have PHP grab the string format when it loads $settings, and adding that to the $o array. JavaScript can then grab that string format and format the epoch accordingly.

I have a working example and can submit a PR if you'd like?

Edit: here's the working example: https://github.com/poblabs/opentrashmail/commit/f82d50b56e27fe4df6e07f74a740284d5cbde352

Logs and account list not secure

While the admin page and password are enabled the logs/accounts list pages are still accessible without a password by going to /logs and /listaccounts respectively

E-Mail not displayed on Webinterface

Steps to reproduce:

  1. run using docker as described in readme
  2. send e-mail

expected behaviour:

  • e-mail gets saved to disk
  • e-mail gets displayed on webinterface

actual behaviour:

  • e-mail gets saved to disk
  • e-mail doesn't get displayed on webinterface

Starting Open Trashmail
From https://github.com/HaschekSolutions/opentrashmail
6fec905..cc7b184 master -> origin/master
Updating 6fec905..cc7b184
Fast-forward
web/api.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[+] Starting php
[+] Starting nginx
[+] Setting up config.ini
[i] Active Domain(s): mytestdomain.xyz
[i] Setting up dateformat to: 'D.M.YYYY HH:mm'
[+] Starting Mailserver
[i] Starting Mailserver on port 25
2021-07-11 15:13:15,569 - main - DEBUG - Receiving message from: 1.2.3.4
2021-07-11 15:13:15,570 - main - DEBUG - Message addressed from: [email protected]
2021-07-11 15:13:15,570 - main - DEBUG - Message addressed to: ['[email protected]']
2021-07-11 15:13:15,578 - main - DEBUG - Subject: Test

Mailserver and Addresses have been replaced by example.com, mytestdomain.xyz and 1.2.3.4

How to disclose a potential security issue?

Hey there,

As there isn't a SECURITY.md or contact address in your repository, I am not sure how to contact you regarding a potential security issue.

Would you kindly provide an email so I can send you the details? Else, simply add a SECURITY.md file with an e-mail to your repository. GitHub recommends this as the best way to ensure security issues are responsibly disclosed. Or perhaps I should just email @geek-at directly?

Look forward to hearing from you, thanks!

Repeated uncaptured exception

Error is repeated for several emails over and over again, in the UI no information is shown, however, the file stored seems to be half written

Error;

error: uncaptured python exception, closing channel <smtpd.SMTPChannel connected <IP>:4996 at 0x7ff4397f57d0> (<type 'exceptions.UnicodeDecodeError'>:'utf8' codec can't decode byte 0xe0 in position 6753: invalid continuation byte [/usr/lib/python2.7/asyncore.py|read|83] [/usr/lib/python2.7/asyncore.py|handle_read_event|449] [/usr/lib/python2.7/asynchat.py|handle_read|165] [/usr/lib/python2.7/smtpd.py|found_terminator|181] [mailserver.py|process_message|145] [/usr/lib/python2.7/json/__init__.py|dump|189] [/usr/lib/python2.7/json/encoder.py|_iterencode|434] [/usr/lib/python2.7/json/encoder.py|_iterencode_dict|408] [/usr/lib/python2.7/json/encoder.py|_iterencode_dict|390])
error: uncaptured python exception, closing channel <smtpd.SMTPChannel connected <IP>:61516 at 0x7ff4397f57d0> (<type 'exceptions.UnicodeDecodeError'>:'utf8' codec can't decode byte 0xe0 in position 6753: invalid continuation byte [/usr/lib/python2.7/asyncore.py|read|83] [/usr/lib/python2.7/asyncore.py|handle_read_event|449] [/usr/lib/python2.7/asynchat.py|handle_read|165] [/usr/lib/python2.7/smtpd.py|found_terminator|181] [mailserver.py|process_message|145] [/usr/lib/python2.7/json/__init__.py|dump|189] [/usr/lib/python2.7/json/encoder.py|_iterencode|434] [/usr/lib/python2.7/json/encoder.py|_iterencode_dict|408] [/usr/lib/python2.7/json/encoder.py|_iterencode_dict|390])

Let me know if you'd like the partial file sent over in private

README Improvements

Hey there!

I was looking over your project and setting it up to use it myself. As I was going through the README, I noticed a handful of spelling and grammar errors.

Would you have an interest in me submitting a PR to fix those? They're already up on my branch here.

Docker for ARM

Have you build a docker for ARM? I am interested to use opentrashmail on raspberrypi.

Admin account returning no emails

Not sure if I'm misunderstanding the limited docs, but when attempting to set the admin account with the docker image I'm unable to view all emails sent to the server, instead only seeing messages sent to the set address.
Docker logs confirm that the value has been read with [i] Set admin to: "[email protected]"

I have tried setting the ADMIN environment variable to different values such as admin and [email protected] to no success, even attempting addresses that are not on the hosted domain.

Date format value ignored

Setting the DATEFORMAT variable for the container the WebUI displays no changes.

For example;
Date format; dddd, MMMM Do YYYY, h:mm:ss a
Expected output; Wednesday, November 8th 2023, 3:36:17 pm
Actual output; 2023-11-08T15:36:17+00:00

undefined function mime_content_type()

This is a fun project, thanks for creating it! Today when I was playing around with it in a Docker container, I used Outlook to send an attachment of a screenshot saved in JPG, and when I received the email in opentrashmail, I get the subject and body. When I click on the attachment link I received:

Fatal error: Uncaught Error: Call to undefined function mime_content_type() in /var/www/opentrashmail/web/api.php:34 Stack trace: #0 {main} thrown in /var/www/opentrashmail/web/api.php on line 34

I'm not sure how else to help, my docker troubleshooting skills aren't the best. Let me know how I can assist.

Feature request; option to add random characters to addresses

It'd be nice to increase the randomness of addresses generated to help reduce the effectiveness of brute-force API checks.

For example, being able to swap a word for a number of random characters in either the username or subdomain if using wildcard domains.

This would make addresses less memorable but it could be recommended that users bookmark the URL to regain access upon generating a new address.

mailfrom.endswith block all

Hi
I have a problem with blocking emails that do not come from a specific domain.
The mailfrom.endswith element works independently in test but in the server all received mails are "Email not trusted".
if (not mailfrom.endswith("@mydomain.com") or not mailfrom.endswith("@mydomain2.com")): raise Exception("Email not trusted")

Discarding email even though correct domain

Docker output

Starting Open Trashmail
 [+] Starting php
 [+] Starting nginx
 [+] Setting up config.ini
   [i] Active Domain(s): 0xfs.eu
   [i] Setting up DISCARD_UNKNOWN to: true
   [i] Using default dateformat
 [+] Starting Mailserver
[i] Starting Mailserver on port 25
2022-07-27 08:06:17,750 - __main__ - DEBUG - Receiving message from: 209.85.222.174:44678
2022-07-27 08:06:17,751 - __main__ - DEBUG - Message addressed from: xyz
2022-07-27 08:06:17,751 - __main__ - DEBUG - Message addressed to: ['[email protected]']
2022-07-27 08:06:17,776 - __main__ - DEBUG - Subject: test
2022-07-27 08:06:17,777 - __main__ - INFO - Discarding email for unknown domain: 0xfs.eu

Error starting mailserver

I get an error starting mailserver on port 25, even though I chose a different port.
Google says, it is because it is being started as non-privileged user nginx.
su - nginx -s /bin/ash -c 'cd /var/www/opentrashmail/python;python mailserver.py'

error: uncaptured python exception

Hi there,
Firstly, thank you for the great app!
Since I installed it 2 weeks ago It was working for me smoothly . Unfortunately today I started receiving error message like this on every email I've got.

error: uncaptured python exception, closing channel <smtpd.SMTPChannel connected 209.85.160.180:40637 at 0x7f906b043320> (<type 'exceptions.NameError'>:global name 'em' is not defined [/usr/lib/python2.7/asyncore.py|read|83] [/usr/lib/python2.7/asyncore.py|handle_read_event|449] [/usr/lib/python2.7/asynchat.py|handle_read|165] [/usr/lib/python2.7/smtpd.py|found_terminator|181] [mailserver.py|process_message|92])��Starting Open Trashmail

Limit attachment size

Could you add the possibillity to limit the attachment size? or the total email size to lets say 2Mb?

500 Error: (TypeError)

Hi there,

first off, i love this project. I set this one up in no time using docker. Regular emails work fine, but when adding attachments, i am getting:

500 Error: (TypeError)
'NoneType' object is not subscriptable (in reply to end of DATA command)

i am using hascheksolutions/opentrashmail:latest

Emails are stored as root:root

I ran a password-less opentrashmail for a few months, which of course has attracted spammers/robots, etc. I start it the following way:

docker run -d --restart=always --name opentrashmail -e "DOMAINS=XXXXX" -e "DATEFORMAT='YYYY-M-D HH:mm'" -p 80:80 -p 25:25 -v /home/qdii/opentrashmail/data:/var/www/opentrashmail/data hascheksolutions/opentrashmail

However I noticed that the emails are stored either as user "uuidd" (group id 101), or "root"

$ ls -l | tail
drwxr-xr-x 2 root  root  4096 Jan 23 16:42 [email protected]
drwxr-xr-x 2 root  root  4096 Jan 23 16:42 [email protected]
drwxr-xr-x 2 root  root  4096 Jan 23 16:42 [email protected]
drwxr-xr-x 2 uuidd uuidd 4096 Jan 12 07:11 [email protected]
drwxr-xr-x 2 uuidd uuidd 4096 Jan 12 07:11 [email protected]
drwxr-xr-x 2 uuidd uuidd 4096 Jan  2 01:22 [email protected]
drwxr-xr-x 2 root  root  4096 Jan 24 12:14 [email protected]
drwxr-xr-x 2 root  root  4096 Jan 23 16:42 [email protected]
drwxr-xr-x 2 root  root  4096 Jan 23 16:42 [email protected]
drwxr-xr-x 2 root  root  4096 Jan 23 16:42 [email protected]

That sounds a bit wrong.

Attachments won't open

When I try to open any attachment I get this message: {"status":"err","reason":"File not found"} in the browser.
The file is stored in the file system in the attachments directory
Any idea how to fix?

Thanks

Admin mailbox does not auto refresh

I'm working on a PR for a few bugs I'm seeing, but I wanted to document this one too. When you first open the site and you first access the admin account, the setInterval(updateEmailTable, 5000) isn't invoked. Don't know why yet.

If you load another non-admin account, it works, and if you then go to the admin account, it works because the setInterval is already set.

In some cases, the setInterval is set two times.

Attached images in HTML preview do not work

Attached images in HTML preview section do not render. Here is an example:

Image kinda big

Screenshot from 2022-05-09 12-17-22

The images' src is always a non-URL. For example:

A fix for this issue is to rewrite the image tag's src in the HTML preview section. cid:[email protected] would become http://example.com/api.php?a=attachment&[email protected]&id=12345&filename=test.jpg.

Also, < and > is getting rendered inside the Raw Email section as HTML. These characters need to be escaped.

Allowing for random subdomains

Would it be possible to allow for domains with random subdomains?

If I have example.com as my domain, I would like to generate <adjective>.<noun>@<other random word>.example.com

function generateRandomEmail() $nouns $adjectives

The $nouns $adjectives arrays are set twice.

I was wondering why i kept getting the same email addresses.
found that it was set twice. For now i commented the duplicate out.

worth fixing :)

-Dennis

Random generation does not work

It seems like the random generation button does not work . nothing seems to pop up in the console log.

Edit
localhost are logged in the console only

delete attachment

Hi,

deleting an email does not delete the attachment.

nothing in the logs,.

-Dennis

"Generate random" button does not work in docker with no domain

Config:

  • Run in docker
  • No domain configured

Command: docker run -it -p 25:25 -p 80:80 hascheksolutions/opentrashmail

Then try to Generate Random


From my test, it seems like it randoms something like this: duddy-window@localhost and loadAccount does not accept this as it is not a valid email.

Maybe adding an alert if the domain is not set?

How to configure multiple domain ?

Hi,

First, thanks for your job.

I would like to configure multiple domain and tried this command :

docker run -d --restart=unless-stopped --name opentrashmail -e "DOMAINS=test.fr, test2.fr test3.fr" -e "DATEFORMAT='D.M.YYYY HH:mm'" -e "DISCARD_UNKNOWN=true" -e "DELETE_OLDER_THAN_DAYS=1" -p 80:80 -p 25:25 hascheksolutions/opentrashmail

But that did not works.

Is it possible ?

Thanks

template rss.xml.php

Hi there,

rss.xml.php needs some fixing.

The view raw email link is not pointing to the actual email.

It should look like this:

<a href="<?= $url ?>/api/raw/<?= $email ?>/<?= $id ?>">View raw email</a> <br/>

https for Web interface

lack of https security while reading mail - even trash mail.. sounds like a crazy thing.
Even self-signed sertficate would be "good" and enough for such service.

Can access admin page without password

The newly added admin page can be accessed without being prompted for a password.

From a quick read of the code it appears that the environment variable ADMIN_PASSWORD isn't being passed to the config file within start.sh, not sure if this is the cause but it very well may be.

Admin mode header issues

When accessing account for ADMIN user, the AJAX call makes the header th's start to stack instead of reloading properly.

on docker

image

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.