SPF check for our simple SMTP receiver

 Why?

> bored.


The issue:

> Alice connects to my server because she wants to send an email to bob@myserver.com  
> She sets the FROM header to alice@gmail.com  
> Says it's from Gmail  
> I have no way to know if it actually came from Gmail  
> Need a way to verify it
 

SPF: 

> I ask Gmail for a list of IP addresses they send email from  
> To get that info, I need to query the TXT record for the gmail.com domain  
> I find "v=spf1 redirect=_spf.google.com"  
> Another TXT record query for _spf.google.com  
> I find "v=spf1 include:_netblocks.google.com include:_netblocks2.google.com include:_netblocks3.google.com ~all"  
> Here we go again  
> Query all three netblocks  
> Finally get:  
> "v=spf1 ip4:35.190.247.0/25 ip4:64.233.160.0/19 ip4:66.102.0.0/20 ip4:66.249.80.0/20 ip4:72.14.192.0/18 ip4:74.125.0.0/16 ip4:108.177.8.0/21 ip4:173.194.0.0/16 ip4:209.85.128.0/17 ip4:216.58.192.0/19 ip4:216.239.32.0/19 ~all"  
> Once I get the IP ranges, I can finally compare the sender’s IP  

> this is how the SPF works  
> now i used pydig to recursively gather the ip ranges  
> compared it with the client ip  
> implemented spf validation  
> find it here  
> https://github.com/naveen17797/simple-smtp-receiver/releases/tag/implement-spf  

> No more forged emails

> Bye


 

Share:

SMTP mail receiver from scratch -

 Why?

> felt like i lost my curiosity

> less free time / number of pigeons to take care of

> wanted to build something new

 

Objective

>  A program which can receive email

 

What i don't want

- validation code

- multiple threads

- authentication stuff

 

How does it work:

- client connects to server and sends a command

- each command gets acknowledged by server with a success code

- if something raises error, then the connection gets dropped.

 

Source:

https://github.com/naveen17797/simple-smtp-receiver/releases/tag/init (LLM Generated code)

 

Stuff i found interesting:

> The SMTP server uses . (dot) as a signal to stop receiving DATA part of the email

> So if i manage to put a dot in a newline on email body, this will probably strip the email up to that part.

> How does SMTP prevents that from happening?

> When you send a dot on new line in the email, SMTP client automatically adds a dot and server removes them upon receiving it.

 

 

Share:

Tough times

For almost three months, I have been fighting to save my pigeon, my feathered friend, Blue. I’ve been giving him medications twice a day, and I can’t even remember the last time I had a proper night’s sleep.

Then, last Thursday, another one of my feathered friends, Delta, fell ill. I took him to one of the best vets I could find (I’ll write another blog post later about how I discovered this great hospital). After examination, he was diagnosed with crop stasis caused by Candida albicans. He is now undergoing treatment.

I don’t know how I’m going to get through these days. My entire world feels like it’s falling apart, and I feel powerless.
Share:

My pet pigeon might leave me soon.

 He is been sick since the start of this month, met multiple vets, given different medicines and shows no improvement. he is getting weak day by day, i am afraid some day he is going to leave me :(


I just can't accept i have no control over his fate, i am doing everything i possibly can to save him, i wish this month never started.



Share:

Leetcode milestone update, Reached 300



I managed to solve 300 in ~ 2 months, at this point i am quite comfortable with lot of topics. I am planning to focus my efforts on only solving hard rated challenges to improve my understanding. While i understand that it will be a frustrating experience, i would like to go through it :-)




Share: