Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Email Program
Index -> Programming, C -> C Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Nikola




PostPosted: Thu Jun 05, 2008 11:34 am   Post subject: Email Program

Im working on a summative that is too come and was wondering if it was possible to have my code connect to the internet to actualy send an email. My program right now is just a mock email program that reads premade templates from a db and can send emails by placing it into a db but i would love if it could make it really send the email. Is there any code for this? I've search on google and etc but i couldn't find anything. Please help!

-Nikola J
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu Jun 05, 2008 11:42 am   Post subject: RE:Email Program

You've got to run a mail-server (such as [url=http://en.wikipedia.org/wiki/Postfix_(software)]postfix[/url]) locally, or connect to another server that has similar functionality.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
btiffin




PostPosted: Thu Jun 05, 2008 5:27 pm   Post subject: Re: Email Program

If you have access to an SMTP (or more frequently now, ESTMP) server name, the SMTP protocol is fairly simple. Nearly all Internet accounts come with this from your ISP and you get instructions from them so you can configure your email client.

For instance, my server is smtp.broadband.rogers.com, yours will be provided by your ISP. Access to these servers don't even need to be from your own account. As long as the user name and password match, it'll be all good.

Check http://en.wikipedia.org/wiki/SMTP#Sample_communications to see how easy it is to send email. ESTMP complicates things just a little bit by requiring a password (a spam fighting measure that slowed the bad guys from hijacking Windows machines and sending a few emails a minute from millions of unsuspecting home users). After scanning the SMTP protocol, a quick check of the ESTMP protocol will show you the extra EHLO sequence required for passwords. EHLO is the Extended HELO part of the SMTP protocol. Just about every major ISP will require EHLO now a days.

Basically; a plain text file transmitted to your server will trigger sendmail.

WARNING: If you go this route, do NOT embed your email password in C source code. Obfuscate it somehow, or prompt for it. Once someone has your ESMTP password they can send emails that look like they came from you, or more likely, to send Viagra (or worse) spam; which many ISPs will detect and then cut you off the internet until you correct the situation, which can be a hassle.

Double WARNING: Your email password is very likely the same as your internet account password, so not only does it open up a huge spam hole, people that get your password can log on to the internet through your account. Don't expose yourself to Nasty McNasty using your account to get YOU in trouble. If you are Canadian, everything you do on the Net is monitored by the US government so it is pretty easy to get in some real trouble if people get access to your account.

And just so ya know; Tony's suggested solution will teach you a lot more, so it is worth following up on.

Cheers
Edit; added more to the warning.
Vermette




PostPosted: Fri Jun 06, 2008 9:33 am   Post subject: RE:Email Program

Not likely it's this easy anymore, but I remember telnetting into mail servers and performing the SMTP handshaking MANUALLY, essentially crafting my email right on their server. It was a good joke to send people spoofed emails, but yeah in the spam age it's not so easy Razz
btiffin




PostPosted: Fri Jun 06, 2008 11:43 am   Post subject: RE:Email Program

Yep; it is still as easy as. ESMTP only adds the requirement that you have a password and use EHLO instead of HELO in the telnet conversation.

Better still is just create a text packet and send it over raw TCP to a server. But if you spam, ISPs are much better at detecting such activity and if done too much you can get your ISP connection suspended. Which can be a real hassle. SPAM is bad. It tastes like sawdust and wastes everyones time. Smile My apologies to Hormel Foods.

Cheers
Nikola




PostPosted: Mon Jun 09, 2008 11:50 am   Post subject: RE:Email Program

Thanks for all of the help guys but i still need to know how to code it into my program! I want the program to ask for a string and then once enter is sent to send the email to the person. I have read up on what you have told me (SMTP) but it still doesn't help all that much when it actualy comes to coding it into the program. Can anyone please give me a direct example of a program with it? Thanks again for all the help!
btiffin




PostPosted: Mon Jun 09, 2008 3:36 pm   Post subject: RE:Email Program

Try this link; It'll require a little digging to get all the pieces together (and hopefully by digging, understanding as well).

http://www.example-code.com/C/smtp.asp

There are a thousand and one other ways of accomplishing this, but chilkat is pretty good at providing examples that teach good practices.

Cheers
Edit; First message sounded like I was talking down, so I changed it; talking down is rarely (never) my intent.
Display posts from previous:   
   Index -> Programming, C -> C Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: