subject: HOW TO SEND AN EMAIL 101
Howdy!
Today we will be learning how to send an email!!
Lets dive in shall we?
So what is an email?
Let me break it down for you in a way that will make your black-painted nails and dark heart sing.
So, you know how you can send instant messages to your friends, right?
Well, emails are like messages, but they're sent through a special system called SMTP (Simple Mail Transfer Protocol).
Think of it like this: you're writing a letter (the email), and you need to put it in an envelope (the SMTP). Then, you give the envelope to a mail carrier (the internet), who takes it to the post office (the recipient's email server), where it gets delivered to the recipient's mailbox (their email inbox).
SMTP is the system that takes care of the envelope and delivery process. It makes sure that your email gets to where it needs to go, and it's responsible for things like checking that the email address is valid and handling any errors that might come up along the way.
You can use SMTP to your advantage. For example, you can use it to send emails that look like they're coming from someone else (known as spoofing)! its like putting on a mask on Halloween and screaming LOOK AT ME!
Lets get into how we can do this...
First steps:
lets create a new project
next we need to open up that Cargo.toml in our preference of IDE and slap in our much needed dependencies
cool now open up src/main.rs and and the ones we will be using right on top :3
epic now we need to add some code lets start with a new function
meowzers! now what do you think this does?
this generates a random email address! this way you dont have to sign up for like 55-5000 email addresses, I don't even know how to sign up for email, so this is my best method!
local_part is just the username that we will randomly generate
domain_name just generates a random domain name
and tld just uses a random one in our list, (tld is what comes at the end of a domain lol)
next lets define a send_email function to handle processing of sending emails.
okay so we define this with async as we want it to be asynchronous as well as pass the email we want to send to, the subject, and the body.
then we create the email format!
the from address we just have set to call the function we made earlier random_email_address
then we have the to, subject, and body, we will have those set as arguments later on in the next function
Next we have to setup the SMTP client
so this is the SMTP client, we define our credentials in it, replace mail.tcp.wiki with your own smtp server and g1r and the password with your own :D
then we have spawn_blocking, basically we are using tokio's multi-threading to send as many emails as you want fast and efficiently,
now to move onto the main function
so here we set the arguments!
as you can see we have a usage arg aswell to explain how to use it
now lets add the Tokio runtime
so now we take the num_emails value and set that to the amount of threads and spawn a task in the amount of emails then take the to email, subject, and body and send it to the send_email function!!!
SICK now lets test it!!
we will use temp-mail.org for testing!
now once u have your targets email address you can go ahead and run the binary
remember replace the email with the one you want to email, if you haven't compiled it yet run
now lets see the results...
hhhHURRAY!! WE SENT AN EMAIL!!!!
Remember, this is just a fun little project, so please don't use it for anything naughty! π€
Feel free to leave your thoughts and suggestions and SPAM in the comments.
Stay dark, shady and mysteriousπ
Comments
Displaying 1 of 1 comments ( View all | Add Comment )
mit
meow emial
Report Comment