LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 05-12-2007, 01:41 AM   #1
WinX187
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


hey,

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:

Code:
Connected to Host.

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

Prompt >helo

MAIL from: from@from.com
250 from@from.com... Sender ok

RCPT To: rcpt@rcpt.com
250 rcpt@rcpt.com... Recipient ok

DATA
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:

Code:
send_socket(DATA);
read_socket(); 

infile = fopen(file, "r"); /* open file */
while(1)
{
 if(fgets(filedata, 100, fin)==NULL) /*reads and prints file till EOF*/
        break; 
 send_socket(filedata);
}
fclose(infile); /* close file */
 
Old 05-12-2007, 06:35 AM   #2
mechdave
Member
 
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
 
  


Reply


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 02:10 AM
unix/socket programming, which book should i read first ??? b0nd Linux - General 2 05-06-2006 12:47 AM
Can't send email using SMTP...stuck smiley_lauf Linux - Newbie 4 01-31-2006 08:20 PM
can't send email, smtp or sendmail dtra Linux - Software 1 11-19-2005 06:00 PM
Unix socket programming - how to sent a file Scrag Programming 9 03-28-2004 09:54 PM


All times are GMT -5. The time now is 07:38 PM.

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