Are there any self-hosted, modern mail servers (similar to Sendgrid, AWS SES, etc.)? reddit / selfhosted ---------------------------------------------------------------------- collimarco · 2023-11-27 15:20 I have just found this interesting project for Rails after a lot of research: [https://github.com/postalserver/postal](https://github.com/postalserv er/postal) **I wonder if there are any other promising projects out there.** The idea is to have a scalable service like Sendgrid, Postmark or AWS SES, .... but self-hosted. ---------------------------------------------------------------------- autogyrophilia · 2023-11-27 17:04 Modern it's very broad word there . Mailcow, which I heavily recommend, RedMail and Mailinbox are based on modern stacks of email. There it's also Proxmox Mail Gateway, which is only an SMTP relay, but I quite like it's interface. For the features this service provides, I can't help but recommend PMG as a better alternative, it's the same software stack with a much better interface. Of course none of these tools have the management capacities of Microsoft Exchange, but are an step up from webhosting email servers. Those three webserver are scalable because they do a lot of filtering, they embed tags categorizing content. All to avoid mail being rejected. Their IPs are widely trusted as well. Your self hosted email does not have that capability. Be it Postfix or Exchange. Now, if you mean, capable of using webhooks? That's also very simple to implement, here is a quick boilerplate made in Python (and with 0 security) for a webserver : ​ `from fastapi import FastAPI, HTTPException` `from pydantic import BaseModel` `import smtplib` `from email.mime.text import MIMEText` `app = FastAPI()` `class EmailSchema(BaseModel):` `to_email: str` `subject: str` `body: str` `@app.post("/send_email/")` `async def send_email(email: EmailSchema):` `try:` `# SMTP Configuration` `smtp_server = 'your_smtp_server'` `smtp_port = 587 # Update with the appropriate port` `smtp_username = 'your_username'` `smtp_password = 'your_password'` `# Create the message` `message = MIMEText(email.body)` `message['Subject'] = email.subject` `message['From'] = 'your_email@gmail.com' # Update with the sender's email address` `message['To'] = email.to_email` `# Connect to the SMTP server` `with smtplib.SMTP(smtp_server, smtp_port) as server:` `# Log in to the SMTP server` `server.starttls() # Use if your server requires a secure connection` `server.login(smtp_username, smtp_password)` `# Send the email` `server.sendmail(message['From'], [message['To']], message.as_string())` `return {"message": "Email sent successfully"}` `except Exception as e:` `raise HTTPException(status_code=500, detail=f"Failed to send email. Error: {str(e)}")` And you would send a email like this : ​ `curl -X POST "http://127.0.0.1:8000/send_email/" \` `-H "Content-Type: application/json" \` `-d '{"to_email": "recipient@example.com", "subject": "Test Subject", "body": "Test Body"}'` ---------------------------------------------------------------------- releenc · 2023-11-27 21:05 I really like hMailServer for Windows. Includes both transport and backend server supporting POP and IMAP clients. Supports proper encryption and SPAM filters. No longer supported but still available.