Jump to content
  • Advertisement
Sign in to follow this  
Peter Conn

How do I send an email

This topic is 4495 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hiya I am using C++ and I want to send emails with my program, how would I go about doing this? Would I have to log into an existing email account? Are tehre any tutorials that could help me?

Share this post


Link to post
Share on other sites
Advertisement
Google the SMTP protocol.
If youre using winsock you just connect to a smtp server and hand over
the information of the mail you want to send using smtp commands.

Share this post


Link to post
Share on other sites
The SMTP protocol is really simple. You just connect to a mail server on port 25, and send text commands. Each line is terminated with \r\n (not just \n).
Example transaction:

220 Druinksoft SMTP server ready BIG TIME.
HELO Test
250 Hello Test [84.19.241.66]
MAIL FROM:<Steve@Foo.com>
250 OK, Sender Accepted
RCPT TO:<You@Bar.com>
250 Ok, that is a valid mailbox.
DATA
354 Please start mail input.
This is a test E-Mail. How exciting.
.
250 Mail queued for delivery.
QUIT
221 Closing connection. Good bye.



When you send DATA, the server takes everything you send from then on, and sticks it into an e-mail. You tell it you're done by sending "\r\n.\r\n".
If you want a SMTP server to test on, feel free to use mine (thetavern.servebeer.com, port 25). I wrote it myself, so it might not be 100% accurate to the spec, but it works well enough for my needs [smile]

My SMTP server won't relay any mail though (I keep getting spammed by test bots...). If you want to actually do this in final code, you'll need to either look up the MX record of the target server (which is hard), or just send the e-mail to your ISPs SMTP server, and they'll relay it for you. But the program will need to know the SMTP server of the end user, which might be a pain to try and get.

Share this post


Link to post
Share on other sites
As for why I asking is because there's this piece of software called SEO Elite that searchs something on google and then automatically emails requests for reciprotal (spelling?) links to the webmasters (aswell as some other stuff). I just wanted to see if I could make a program that could read two text files, one with the message and one with a list of websites. It would then read the list and go through a loop and send an email to each of the webmasters. Therefore saving time and money.

Btw why would you be suspicious of this post?

Share this post


Link to post
Share on other sites
Quote:
Original post by Peter Conn
Btw why would you be suspicious of this post?


Because that's exactly the sort of thing that spammers want to use (of course, they already have plenty of options out there), and it's not really a common request.

Anyway, it is probably more "normal" to shell out to another program for this sort of thing (such as Unix 'sendmail'). It's also probably much better done in a scripting language rather than in C++.

Share this post


Link to post
Share on other sites
Quote:
Original post by Peter Conn
I just wanted to see if I could make a program that could read two text files, one with the message and one with a list of websites. It would then read the list and go through a loop and send an email to each of the webmasters. Therefore saving time and money.


It might be easier to do this (or other things involving manipulating text files) in a scripting language like perl than C++. Here is a link explaining some of the ways perl handles email.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!