GithubHelp home page GithubHelp logo

o4oren / ad-hoc-email-server Goto Github PK

View Code? Open in Web Editor NEW
377.0 13.0 90.0 6.63 MB

An ad-hoc disposable temporary mail server. Create and use ad hoc disposable mailboxes for testing or any other purpose.

License: Apache License 2.0

TypeScript 37.00% JavaScript 16.78% HTML 21.51% CSS 17.82% Dockerfile 0.09% API Blueprint 4.42% SCSS 2.39%
mail mailbox mailboxes mailserver webmail ahem-server disposable-email temporary-email disposable-emails

ad-hoc-email-server's Introduction

Build Status

Ad Hoc Email Server (AHEM)

Ad Hoc Email Server is, well, an ad hoc mail server. AHEM can be used for testing, where a large (or unknown) number of mailboxes are needed or to provide disposable emails for registering for services that might expose the email to spam; This project will provide both a RESTful API and web application for consuming the service.

Getting Started

AHEM will accept any email sent to it (on the domains specified in the configuration), and create an ad hoc mailbox as needed. Then just browse to its UI, enter the mailbox name and you'll see the emails contained in the mailbox. That's it. No authentication. No account creation.

Prerequisites

nodejs > v10 
angular cli installed globally (npm install -g @angular/cli)
mongodb

Installation

# clone the repository
git clone https://github.com/o4oren/Ad-Hoc-Email-Server.git
cd Ad-Hoc-Email-Server
npm install
# builds the project.
npm run build:ssr

# there are other, convenience options for build and run in development mode.
# for development:
npm run startDev

# for prod:
# will run the backend which will also serve the front end from the `dist` folder.
node ahem.js

Configuration

AHEM use several environment variables for configuration. These can be set up using a .env file (see dotEnv docuemntation). An example file is located in the root of the project. If a .env file is no found, you can just set these items as env variables. A docker-compose file is also present in the root of the project, showing how these configuration properties can be set in a docker compose set up or passed to a docker image.

These are the available parameters:

Parameter Description
serverBaseUri The base address for your API server.
mongoConnectUrl The mongodb connect URL in the form of "mongodb://localhost:27017/ahem".
appListenPort The port the node app will bind to.
smtpPort The SMTP server's port. Note that by default it is set to 2525 - this is done for testing purposes, as on many systems only a system account can listen on port 25.
emailDeleteInterval The time in seconds between age checks for purging old files.
emailDeleteAge The age in seconds above which emails will be deleted.
allowedDomains An array of allowed email domains. These domains will be allowed by the server as RCPT TO: entries. This also makes the server not act as an open relay. Format: ["my.domain.com", "my.second-domain.com"].
customText HTML string that will replace the default text in the landing page.
allowAutocomplete If set to false, will prevent auto completing users in the ui.
jwtSecret The JWT secret, if using token authentication.
jwtExpiresIn JWT token TTL in seconds. -1 means token validation is not enforced.
maxAllowedApiCalls If using token validation, this is the amount of API calls a token is allowed to make.

Docker

  • Build docker: docker build -t o4oren/ahem .

  • Build FE only: docker build -t o4oren/ahem-universal . -f Dockerfile_ssr

  • Run docker with external properties: docker run -v /[local.dotEvn.path]/.env:/opt/ahem/.env -it -p 3000:3000 -p 25:25 -d o4oren/ahem

  • Sign into docker: docker exec -it ahem sh

  • start docker stackand swarm: docker swarm init && docker stack deploy -c docker-compose.yml ahemswarmc

  • stop docker stack: docker stack rm getstartedlab

  • In addition, sample kubernetes yaml config files are provided as reference in the k8s folder. These are provided as is.

  • for debugging - run mongo on docker locally: docker run -d -p 27017:27017 -v ~/data:/data/db mongo

Build and run with mongodb

  • docker-compose build
  • docker-compose up

Palette

The AHEM color palette is available here.

API

A brief list of RESTful resources:

HTTP Method URI Path Parameters Description
POST /api/mailbox/autocomplete { "prefix":"value" } Returns a partial list of mailboxes.
GET /api/properties Returns global system properties.
POST /api/auth/authenticate { } Returns an access token.
GET /api/mailbox/{mailbox}/email Returns a list of the email objects in the mailbox.
GET /api/mailbox/{mailbox}/email/{emailId} Gets the contents of a specific email.
PATCH /api/mailbox/{acount}/email/{emailId} {"isRead" : true} Updates the emailInfo object (representation of the email meta data in the mailbox). Currently, only the isRead field is supported.
GET /api/mailbox/{mailbox}/email/{emailId}/attachments/{filename} Downloads a specific attachment from an email.
DELETE /api/mailbox/{mailbox}/email/{emailId} Deletes a specific email.
DELETE /api/mailbox/{mailbox} Deletes a whole mailbox.

Google Analytics

AHEM server is ready for Google Analytics. By default, when you set it up, it will not send information to GA though. If you'd like to enable GA, add the snippet below in your /client/index.html file's head section, and rebuild the project. Replace XX-XXXXXXXXX-X with your GA id.

  <script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
        (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

    ga('create', 'XX-XXXXXXXXX-X', 'auto');
  </script>

Todo for 1.0

  • Error page when user/email doesn't exist
  • Empty mail page
  • Landing page
  • Errors on find user/email in api
  • Error on non existing user / message
  • Routing for messages
  • Read/unread icons
  • Attachments
  • Allow delete emails
  • Migrate to mongodb
  • Update missing emails page and loading circles
  • Sort out logging
  • Separate mailbox view from email view pages
  • Separate server and webapp properties
  • Better home page
  • Add apis to get mailbox references from email, get mailbox and email counts - both general and in mailbox context

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the Apache v2 License - see the LICENSE.md file for details

ad-hoc-email-server's People

Contributors

dependabot[bot] avatar devanshdalal avatar e2jk avatar gcleaves avatar jetmore avatar neerajkumar161 avatar nmummau avatar o4oren avatar useername 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  avatar  avatar  avatar  avatar

ad-hoc-email-server's Issues

securing the service

Hi,

i don't want my self hosted instance to be available to anyone but me.
I tryied adding an http auth in nginx but it keeps asking me for credentials.
Any idea?

Best regards,
lezioul

Domain Expired ?

The domain www.ahem.email possibly expired and instead of the project's website bunch of malware and ads are showing. Please either re-register the domain or update the website. Thanks.

No mails are received for custom domain

Hi there, I did all the procedures to setup AHEM with a custom domain name of me. I added the domain in the list of properties.jsoon and in the docker-compose.yml
Besides that; I pointed the domain's DNS records to the same IP as the server. however; I don't think that's enough for the app to read the mails.
I mean; the app was built on the server and the front end is working fine and I can generate a mail and it takes me to the mailbox ... however, nothing is received

so could you please make It clear of how to set up the domain to make it working said with the backend?

thanks in advance

Service issue

Hello,

I've been experiencing some service issues with the example app (https://www.ahem.email/) recently. Urls for mailboxes now return 404 when they didn't before (https://www.ahem.email/mailbox/testing) the app does load correctly if I type the username from the homepage but even then it intermittently fails to load emails.

Sorry to post a service issue in this code repo but I wasn't sure where best to direct it. Has this been on your radar at all?

Many thanks!

Mail Tester causes service crash if failed

If the server is misconfigured the mail tester causes a crash, because result is undefined.

logger.info('Mail tester error!', result.result);


{"level":"info","message":"connecting to db"}
(node:1) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
(Use `node --trace-deprecation ...` to show where the warning was created)
{"message":"Connected successfully to mongodb server","level":"info"}
{"message":"starting smtp on 25","level":"info"}
{"message":"API server listening","level":"info"}
{"message":"::ffff:10.175.153.38 - GET /api/alive HTTP/1.1 200 49 - 9.768 ms -\n","level":"info"}
{"message":"SMTP Connect from 127.0.0.1","level":"info"}
(node:1) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
/app/server/app/mailTester.js:61
      logger.info('Mail tester error!', result.result);
                                        ^
ReferenceError: result is not defined
    at /app/server/app/mailTester.js:61:41
    at /app/node_modules/nodemailer/lib/mailer/index.js:226:21
    at /app/node_modules/nodemailer/lib/smtp-transport/index.js:239:32
    at callback (/app/node_modules/nodemailer/lib/smtp-connection/index.js:435:13)
    at /app/node_modules/nodemailer/lib/smtp-connection/index.js:445:24
    at SMTPConnection._actionMAIL (/app/node_modules/nodemailer/lib/smtp-connection/index.js:1370:20)
    at SMTPConnection.<anonymous> (/app/node_modules/nodemailer/lib/smtp-connection/index.js:857:18)
    at SMTPConnection._processResponse (/app/node_modules/nodemailer/lib/smtp-connection/index.js:764:20)
    at SMTPConnection._onData (/app/node_modules/nodemailer/lib/smtp-connection/index.js:570:14)
    at TLSSocket.<anonymous> (/app/node_modules/nodemailer/lib/smtp-connection/index.js:710:55)

How to whitelist port 25

we are Running AHEM on the AWS ec2 machine, Working Fine

we Have enabled Guard duty for every 2 days we are getting alerts on port 25 if probed,

Is there any way to white list the port 25? we tried with the NAT gateway but does not worked

SMTP is not working.

Hi,

Thank you for the great work.
Mails are not getting delivered when running locally.
For Example, I have created a mailbox [email protected] and sending mail to this mailbox from Gmail.
It is not working for me.

Feature request: webhooks

Hi. Very useful project, thanks.

I think a webhook feature would be useful where the admin registers a URL and AHEM hits it every time a new message arrives. The body of the call could contain the mailboxName and emailId.

I wish I could do this myself but my node skills are poor, not to mention TypeScript.

Cheers!

nodemailer should be a production dependency

On production servers where NODE_ENV=production nodemailer wasn't getting installed.
This presents a problem as the code requires nodemailer for the /api/alive route.

nodemailer is required here in mailTester.js.

mailTester.js itself is required here.

Last but not least, you can see nodemailer is a development dependency here.

Programmatic API ?

Hello,

Is there, or could there be, a programmatic API, for this server, so that it can be dynamically used by a parent script to start, receive and stop ?

Thanks

Email Not receiving

I installed Ad-Hoc-Email-Server on my own AWS EC2 instance (Ubuntu 18.04, Nodejs v13.1.0, MongoDB, Nginx).

I also configured the SMTP port as 25 and opened 25 port on Security Groups of my EC2 instance.

And now the backend is working properly.

But when I send an email to [email protected], it doesn't receive anything.

Please guide me how I can resolve this.

Thanks,

The app crashes when testing with telnet

Hello,

I managed to follow your steps and install the app on a windows 7 virtual machine. I started the app with node ahem.js and opened another console to test the email functionality (response from API was already received as: {"success":true,"api":true,"smtp":true,"db":true} ) So, going further, in the new console I followed these steps:

  1. Type the following command: telnet <mail server name or IP> 25
  2. Type: EHLO <mail server internet name>
    Replace with your mail server's public fully qualified domain name - for instance, mail.dell.com.
  3. Type: mail from: <[email protected]> and press Enter.
  4. Type: rcpt to: <[email protected]> and press Enter.
  5. Type: data and press Enter.
  6. Type: Subject: <a subject here> and press Enter.
  7. Type: This is a test message sent from telnet. and press Enter.
  8. Type: . and press Enter

In the ahem.js console I can see the telnet connection, but just when finishing everything up and performing step 8, the ahem.js console crashes with this error:

`{"message":"SMTP Connect from myIpV6 ","level":"info"}
{"message":"SMTP MAIL FROM: [email protected]","level":"info"}
{"message":"SMTP RCPT TO: [email protected]","level":"info"}
{"message":"SMTP DATA start","level":"info"}
{"message":"SMTP DATA end","level":"info"}
E:\tests\EmailServer\Ad-Hoc-Email-Server\node_modules\mongodb\lib\utils.js:132
      throw err;
      ^

TypeError: Cannot read property 'value' of undefined
    at E:\tests\EmailServer\Ad-Hoc-Email-Server\server\app\smtp.js:67:23
    at E:\tests\EmailServer\Ad-Hoc-Email-Server\node_modules\←[4mmongodb←[24m\li
b\utils.js:414:17
    at E:\tests\EmailServer\Ad-Hoc-Email-Server\node_modules\←[4mmongodb←[24m\li
b\utils.js:401:11
    at ClientSession.endSession (E:\tests\EmailServer\Ad-Hoc-Email-Server\node_m
odules\←[4mmongodb-core←[24m\lib\sessions.js:129:41)
    at executeCallback (E:\tests\EmailServer\Ad-Hoc-Email-Server\node_modules\←[
4mmongodb←[24m\lib\utils.js:397:17)
    at E:\tests\EmailServer\Ad-Hoc-Email-Server\node_modules\←[4mmongodb←[24m\li
b\operations\collection_ops.js:876:19
    at handleCallback (E:\tests\EmailServer\Ad-Hoc-Email-Server\node_modules\←[4
mmongodb←[24m\lib\utils.js:128:55)
    at E:\tests\EmailServer\Ad-Hoc-Email-Server\node_modules\←[4mmongodb←[24m\li
b\operations\collection_ops.js:848:5
    at E:\tests\EmailServer\Ad-Hoc-Email-Server\node_modules\←[4mmongodb-core←[2
4m\lib\connection\pool.js:532:18
←[90m    at processTicksAndRejections (internal/process/task_queues.js:75:11)←[3
9m

E:\tests\EmailServer\Ad-Hoc-Email-Server>node ahem.js`

At this point, I'm not really sure how to proceed in testing if everything works. I can see that there are some emails occasionally received from what appears to be an 'alive-test' email box, but that's pretty much it. I don't know if the emails that another app sends, reach this server and I cannot debug it as I don't have access to its logs. Sending an email from outlook won't work because the VM is not accessible from outside, but the other app is within the same network so it will be able to access it. So the only way that I thought of testing was with telnet. Any thoughts?
Looking in mongo, I see that when creating a mailbox from the AHEM UI, nothing happens in the API or in the DB (as in, the mailbox is not created per'say, but it's rather just a redirection). I suppose the mailbox will be created upon receiving the first email?

Thank you,
Feda

Can't receive any email except from my domain

  1. Setup(OK)
  2. Go to the ip:port(OK)
    So, i tried to use it, it store the "tokens" but not the mailboxes(number is always to 0 in the home of the website) and when i try to send an email to [email protected] with gmail i have: 550 5.1.1 [email protected]: Recipient address rejected: User unknown in virtual mailbox table

(mydomain.com is for the example, it's not my domain)

Solved

Error 404 '{"error":"MAILBOX IS EMPTY!"}' in Postman or IDE, but on ahem email ui interface emai is recieved

Hello:)
what can be the reason for error 404 even if on ui (i mean 'https://www.ahem.email/mailbox/N4CNWF') i get the email list, but if i sent the same info(i mean emailName, Bearer token) in Postman or IDE i get. Moreover if i use your doc tool( this one -> https://www.ahem.email/help/api) with same info i also get error 404
https://monosnap.com/file/iinNdniiaonmwbYs2ZQqVgvJ9Gwbuw
https://monosnap.com/file/58XrVtrnj5QpkFCAj7p97cZ2Yq82Ve
here are screenshots for same email and token.
thanks

Missing folder nodes_modules

Hi, While trying to npm install inside the ahem folder, the cmd is trying to hit a path Ad-Hoc-Email-Server\node_modules which is not available in the git pull. Kindly suggest

Snap -
image

npm install issue | Ubuntu 20.04

After running npm install command:

56 packages are looking for funding
run npm fund for details

found 19 vulnerabilities (18 low, 1 high)
run npm audit fix to fix them, or npm audit for details

npm audit fix - do not help
All prerequisites was installed

Cannot find module app/dist

I am trying to run ahem through docker, the ahem-ssr-1 container is returning this kind of error, does anyone have an idea what I can do to solve it?

ad-hoc-email-server-ahem-ssr-1  | internal/modules/cjs/loader.js:965
ad-hoc-email-server-ahem-ssr-1  |   throw err;
ad-hoc-email-server-ahem-ssr-1  |   ^
ad-hoc-email-server-ahem-ssr-1  |
ad-hoc-email-server-ahem-ssr-1  | Error: Cannot find module '/app/dist'
ad-hoc-email-server-ahem-ssr-1  |     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:962:15)
ad-hoc-email-server-ahem-ssr-1  |     at Function.Module._load (internal/modules/cjs/loader.js:838:27)
ad-hoc-email-server-ahem-ssr-1  |     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)

Unable to receive the email

Hi

I have configured the AHEM server and below are the details of the .env file

serverBaseUri= "http://10.135.10.125:3000"
mongoConnectUrl= "mongodb://10.135.10.125:27017/"
dbName= "ahem"
appListenPort= 3000
smtpPort= 2525
emailDeleteInterval= 3600
emailDeleteAge= 86400
allowAutocomplete= true
allowedDomains= "ahem.email"
jwtSecret= "AH3M 709 S3cR3T"
jwtExpiresIn= 3600
maxAllowedApiCalls= 1000

When I open the application with the following url http://10.135.10.125:2500 it's loading the homepage.

when i sent to email ex: [email protected] from my gmail account I'm not getting the any email.
Can you please let me know is anything wrong with my settings? or do I need to add anything?

Use Multiplie Domain

Im' forrmat:
allowedDomains=["my.domain.com", "my.second-domain.com"]
but only show my.domain.com on my web
Please guide me how to use multiplie Domain

Can't receive email

Hi, o4oren

I have setup the mail server and that works fine via api (api/alive)

But when I send the mail to [email protected], it doesn't work.
It returns "Your message wasn't delivered to [email protected] because the address couldn't be found, or is unable to receive mail."

Any configuration I missed?

Kindly need your help ASAP.

Thank you.

cannot add multiple allowed domains in docker-compose.yml

Hi!

AHEM works properly only with one domain in format in docker-compose.yml

allowedDomains=domain.com

If i try use multiple domains, for example:

allowedDomains=domain1.com,domain2.com

or:

allowedDomains=["domain1.com","domain2.com"]

it doesnt work, i cant select domain.. Can anybody helps?

Server stores email sent to random addresses

Hi, I was looking through my MongoDB instance used by AHEM and see emails are being stored even when the recipient address is not in the allowed domains list. Mailboxes are not being created. Is this the expected behavior?

It seems spammers are just looking for mail servers on random IP addresses and stumbled upon my AHEM server.

ways to debug why email is not received

Hi, I've configure the server as follows:

  • ubuntu22.04 ec2 on aws
  • started service on port 3000 and smtp port is 25, allowed origins also configured
  • configured MX and A records for domain
  • api server is working fine
  • opened all ports on ec2 firewall

still not able to get email on mailbox , please suggest things i can check for.

Mailbox appears to be deleted sooner than emailDeleteAge

I've noticed that a mailbox has gone missing from MongoDB but the emails which were part of the mailbox remain. Could it be that the mailbox is not taking into account the emailDeleteAge? I've set mine very high: 2592000 / 30 days.

Cheers.

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.