<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ashish Tiwari</title>
    <description>The latest articles on DEV Community by Ashish Tiwari (@heyashish).</description>
    <link>https://dev.to/heyashish</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4002781%2Ffd10c975-72e6-4b91-9654-eee2c665e43e.jpeg</url>
      <title>DEV Community: Ashish Tiwari</title>
      <link>https://dev.to/heyashish</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/heyashish"/>
    <language>en</language>
    <item>
      <title>Building My Own Mail Server on AWS (And Getting Blocked by Port 25)</title>
      <dc:creator>Ashish Tiwari</dc:creator>
      <pubDate>Thu, 25 Jun 2026 17:17:11 +0000</pubDate>
      <link>https://dev.to/heyashish/building-my-own-mail-server-on-aws-and-getting-blocked-by-port-25-18l9</link>
      <guid>https://dev.to/heyashish/building-my-own-mail-server-on-aws-and-getting-blocked-by-port-25-18l9</guid>
      <description>&lt;h1&gt;
  
  
  Building My Own Mail Server on AWS (And Getting Blocked by Port 25)
&lt;/h1&gt;

&lt;p&gt;Email is something we all use every day.&lt;/p&gt;

&lt;p&gt;Click &lt;strong&gt;Send&lt;/strong&gt;, wait a second, and somehow the message lands in someone else's inbox. It feels simple.&lt;/p&gt;

&lt;p&gt;Until you decide to build the entire thing yourself.&lt;/p&gt;

&lt;p&gt;That's exactly what I did.&lt;/p&gt;

&lt;p&gt;My original goal wasn't to create a production-ready mail server. I simply wanted to understand what actually happens after pressing the &lt;strong&gt;Send&lt;/strong&gt; button.&lt;/p&gt;

&lt;p&gt;So I spun up an EC2 instance, installed &lt;strong&gt;Postfix&lt;/strong&gt; and &lt;strong&gt;Dovecot&lt;/strong&gt;, bought a domain, and started experimenting.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Plan
&lt;/h2&gt;

&lt;p&gt;The plan sounded straightforward.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install Postfix&lt;/li&gt;
&lt;li&gt;Configure Dovecot&lt;/li&gt;
&lt;li&gt;Point my domain's DNS records&lt;/li&gt;
&lt;li&gt;Send my first email&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Easy... right?&lt;/p&gt;

&lt;p&gt;Not exactly.&lt;/p&gt;

&lt;p&gt;Everything went smoothly until I tried sending an email.&lt;/p&gt;

&lt;p&gt;Nothing happened.&lt;/p&gt;

&lt;p&gt;After spending a while checking logs and configurations, I discovered the real culprit.&lt;/p&gt;

&lt;p&gt;AWS blocks outbound traffic on &lt;strong&gt;port 25&lt;/strong&gt; by default to prevent spam.&lt;/p&gt;

&lt;p&gt;So my mail server reached a very interesting state.&lt;/p&gt;

&lt;p&gt;It can receive emails perfectly.&lt;/p&gt;

&lt;p&gt;It just can't send them.&lt;/p&gt;

&lt;p&gt;I've already submitted a request to AWS to unblock port 25, so for now my mail server is patiently waiting for permission to speak.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Rabbit Hole
&lt;/h2&gt;

&lt;p&gt;What I expected to be a small weekend project quickly became one of the most educational side projects I've worked on.&lt;/p&gt;

&lt;p&gt;I finally understood the difference between &lt;strong&gt;SMTP&lt;/strong&gt; and &lt;strong&gt;IMAP&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;SMTP is responsible for sending emails between servers.&lt;/p&gt;

&lt;p&gt;IMAP allows clients like Gmail or Outlook to synchronize your mailbox across devices.&lt;/p&gt;

&lt;p&gt;I also learned why DNS is one of the most important parts of email.&lt;/p&gt;

&lt;p&gt;Without properly configured records, your mail server simply doesn't exist as far as other servers are concerned.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding DNS Records
&lt;/h2&gt;

&lt;p&gt;Building the server forced me to work with several DNS records that I had previously only heard about.&lt;/p&gt;

&lt;h3&gt;
  
  
  MX Records
&lt;/h3&gt;

&lt;p&gt;MX records tell the internet where emails for your domain should be delivered.&lt;/p&gt;

&lt;p&gt;Without them, other mail servers have no idea where your inbox lives.&lt;/p&gt;

&lt;h3&gt;
  
  
  SPF
&lt;/h3&gt;

&lt;p&gt;SPF specifies which servers are allowed to send emails on behalf of your domain.&lt;/p&gt;

&lt;p&gt;It helps reduce spoofing.&lt;/p&gt;

&lt;h3&gt;
  
  
  DKIM
&lt;/h3&gt;

&lt;p&gt;DKIM digitally signs outgoing emails so receiving servers can verify they haven't been modified during transit.&lt;/p&gt;

&lt;h3&gt;
  
  
  Reverse DNS
&lt;/h3&gt;

&lt;p&gt;Many mail providers also verify reverse DNS records before trusting your server.&lt;/p&gt;

&lt;p&gt;Missing this configuration often leads to emails being marked as spam.&lt;/p&gt;

&lt;h2&gt;
  
  
  Email Is Basically a Digital Post Office
&lt;/h2&gt;

&lt;p&gt;One realization made everything click.&lt;/p&gt;

&lt;p&gt;Email works surprisingly similar to the Indian Post Office.&lt;/p&gt;

&lt;p&gt;Your domain acts like the address.&lt;/p&gt;

&lt;p&gt;DNS works like the directory that tells everyone where your house is.&lt;/p&gt;

&lt;p&gt;MX records point to the correct delivery office.&lt;/p&gt;

&lt;p&gt;SMTP transports the letter.&lt;/p&gt;

&lt;p&gt;IMAP lets you visit your mailbox whenever you want.&lt;/p&gt;

&lt;p&gt;Once I started thinking about email this way, the entire system suddenly made sense.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Learned
&lt;/h2&gt;

&lt;p&gt;This project taught me much more than how to configure Postfix.&lt;/p&gt;

&lt;p&gt;It helped me understand:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How SMTP and IMAP work together&lt;/li&gt;
&lt;li&gt;Why DNS configuration is critical&lt;/li&gt;
&lt;li&gt;How MX, SPF and DKIM improve email delivery&lt;/li&gt;
&lt;li&gt;How mail servers discover one another&lt;/li&gt;
&lt;li&gt;Why running a reliable mail server is much harder than it first appears&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What's Next?
&lt;/h2&gt;

&lt;p&gt;The immediate goal is getting AWS to approve outbound access on port 25.&lt;/p&gt;

&lt;p&gt;Once that happens, I'll configure secure email delivery with TLS, improve spam protection, and experiment with running a fully functional self-hosted mail server.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Nobody asked me to build a mail server.&lt;/p&gt;

&lt;p&gt;There are plenty of hosted email providers that solve this problem much better than I ever could.&lt;/p&gt;

&lt;p&gt;I built it simply because I was curious.&lt;/p&gt;

&lt;p&gt;That's one of the things I love most about software engineering.&lt;/p&gt;

&lt;p&gt;Sometimes the best projects aren't the ones that solve a business problem.&lt;/p&gt;

&lt;p&gt;They're the ones that answer a question you've been wondering about for a long time.&lt;/p&gt;

&lt;p&gt;This project may not replace Gmail anytime soon, but it definitely replaced a lot of "I wonder how that works?" with "Now I know."&lt;/p&gt;

&lt;p&gt;Originally published on my portfolio:&lt;br&gt;
&lt;a href="https://ashishtiwari.dev" rel="noopener noreferrer"&gt;https://ashishtiwari.dev&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>learning</category>
      <category>networking</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
