Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 05-12-2007, 02:41 AM   #1
LQ Newbie
Registered: Apr 2007
Location: Dubai
Distribution: Tweaked Windows XP, Just Installed Linux
Posts: 2

Rep: Reputation: 0
Socket Programming: SMTP program to send email through Unix


I got an assignment to produce a program to send mail in Unix somethin like how u can send mail through telnet. Some what an SMTP program.

Is there anyone who can help me out I have a little problem in which I wanna come up with code for SMTP program that sends mail through Unix using Telnet.

I was able to connect to the server, and use commands such as "HELO" and "QUIT" in sendmail using telnet, the only thing I was not able to get to was including a Subject in the email, I can send files but and read them but I am not able to input a message and send it.

Problem basically is : being able to compose a message and send a subject

file usage: <from> <to> <filename>

im trying to get it to be somethin like: <from> <to> <subject>

the output im getting looks like:

Connected to Host.

220 ESMTP Mail 3.8.4-GA; Sat, 12 May 2007 16:30:02 +1000 (EST)

Prompt >helo

MAIL from:
250 Sender ok

250 Recipient ok

354 Enter mail, end with "." on a line by itself

/*Reads the text in the file*/

. //Automatically printed out by the program

250 ACS55034 Message accepted for delivery

Prompt >exit
I pretty much want to mention the Subject, and then be able to type in a message.

The source code i got for the DATA part in the above output looks like:


infile = fopen(file, "r"); /* open file */
 if(fgets(filedata, 100, fin)==NULL) /*reads and prints file till EOF*/
fclose(infile); /* close file */
Old 05-12-2007, 07:35 AM   #2
Registered: Apr 2007
Location: Adelaide, Australia
Distribution: Ubuntu 8.10 and 7.10 server
Posts: 95

Rep: Reputation: 15
You need to look up the mail command in linux, with that it can be done using a bash script


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP UNIX Domain Socket Programming anamericanjoe Programming 2 12-08-2006 03:10 AM
unix/socket programming, which book should i read first ??? b0nd Linux - General 2 05-06-2006 01:47 AM
Can't send email using SMTP...stuck smiley_lauf Linux - Newbie 4 01-31-2006 09:20 PM
can't send email, smtp or sendmail dtra Linux - Software 1 11-19-2005 07:00 PM
Unix socket programming - how to sent a file Scrag Programming 9 03-28-2004 10:54 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:33 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration