C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 26th, 2002, 11:05 PM
swapna swapna is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Inida
Posts: 2 swapna User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 41 sec
Reputation Power: 0
Question C code that follows SMTP protocol

I need C sample code that follows SMTP Protocol to send an email in windows as well as Linux.
Need some one to help me on this?

Reply With Quote
  #2  
Old December 27th, 2002, 08:12 AM
Wingman Wingman is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Bavaria, Germany
Posts: 140 Wingman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 40 m 41 sec
Reputation Power: 11
Here's a sample SMTP session:

Quote:
telnet some.mail-server.com 25

<- 220 some.mail-server.com ESMTP
-> HELO from@from.org
<- 250 some.mail-server.com
-> MAIL FROM: from@from.org
<- 250 some.mail-server.com ok
-> RCPT TO: to@to.org
<- 250 some.mail-server.com ok
-> DATA
<- 354 go ahead
-> From: from@from.org
-> To: to@to.org
-> Subject: subject
->
-> body
-> .
<- 250 some.mail-server.com ok some-id
-> QUIT


Now all you have to do is to write socket code which runs on windows and linux (which isn't hard at all, you just need to include
different header files and initialize the winsock library
on windows).

And please don't bitch me about my c code, it has nearly no error handling, no buffer length checking, no mail server reply checking, ... but it works...sometimes ;-)
Attached Files
File Type: zip smtp.zip (1.1 KB, 5109 views)

Reply With Quote
  #3  
Old December 27th, 2002, 11:08 AM
ClayDowling ClayDowling is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Flint, MI
Posts: 328 ClayDowling User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 19 m 25 sec
Reputation Power: 11
Swapna,

Good luck. Windows and UNIX have very different approaches to the network. Under UNIX systems it is traditional to do a popen on mail or sendmail. A good example can be found at The Unix Programming Resources Page

I don't know of any libraries for Windows that do this. Certainly they're available commercially. If you're in need of something capable of cross-compiling though I think you could be out of luck.
__________________
Clay Dowling
Lazarus Notes
Articles and commentary on web development
http://www.lazarusid.com/notes/

Reply With Quote
  #4  
Old December 27th, 2002, 11:33 PM
swapna swapna is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Inida
Posts: 2 swapna User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 41 sec
Reputation Power: 0
smtp c code

Hi Wingman,

I compiled the file you sent in linux and executed it.

But its giving the message as "Mail successfully sent."(for our local mail server),but at the other end we are unable to receive the mail.

And while trying to send mails to few servers like yahoo.com,hotmail.com etc its giving error
" failed to send mail with code -2"

Thanks
Swapna

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > C code that follows SMTP protocol

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap