Search Tools Links Login

Simple Mail Transfer Protocol

This code will teach you Step-by-Step how to make a simple emailer. I would recommend this if you are looking to make an emailer, anonymailer, or Ezine emailer.

Original Author: Corey langdon (has since resigned)


This code is a little hard to understand but by going over it a few timew you can EASILY understand SMTP.

First we need to connect to an SMTP server like this:

Winsock1.Connect "SMTP server", "25"

Now that we have connected we need to start the transfer:

Winsock1.Senddata "HELO " + Winsock1.LocalIP + vbCrLf

That starts the transfer. Then You need to Specify who is sending the email:

Winsock1.SendData "MAIL FROM:<" + "" + " > " + vbCrLf

That will say who it is from. You then need to say who you want to send it to:

Winsock1.SendData "RCPT TO:<" + "" + " > " + vbCrLf

You have specified who to send it to, now you have to tell the server that you are ready to send the contents of the email:

Winsock1.SendData "DATA" + vbCrLf

These are the contents of the email:

Winsock1.SendData "From: <" + "" + ">" + vbCrLf + _

"To: " + "" + vbCrLf + _

"Subject: " + "Subject" + vbCrLf

When you have done that you are ready to send the Message and Other data:

"Mime-Version: 1.0" + vbCrLf + _

"Content-Type: text/html" + vbTab + "charset=us-ascii" + vbCrLf + vbCrLf & "Message of Email"

Winsock1.SendData vbCrLf + "." + vbCrLf

Now we need to tell the server that we are done sending the email:

Winsock1.SendData "QUIT"

Please Vote for this bcuz i worked on this for awhile and got kicked offline while doing this. I will accept any critisizm as long as it is appropriate and not bagging on me. I would like it if i could get some votes. Also if you copy and paste this and go over it for awhile then you will have mastered this. It only takes 10 minutes. A couple of suggestions if you are going to make this an actual emailer:

-Change the "" and "" to a text box appropriatley fitting them so you can change the Mailer and Reciever.

-Also Put DoEvents: Doevents: Doevents: doevents under The winsock1.Connect "SMTP SERVER", "2"

-Change the "SMTP SERVER" to a combobox or textbox to change servers.

-Email me if you have any Questions.

P.S. I would be in your debt for Five globes :) !

About this post

Posted: 2003-06-01
By: ArchiveBot
Viewed: 89 times


Visual Basic 6


No attachments for this post

Loading Comments ...


No comments have been added for this post.

You must be logged in to make a comment.