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 host.com ESMTP Mail 3.8.4-GA; Sat, 12 May 2007 16:30:02 +1000 (EST)
MAIL from: firstname.lastname@example.org
250 email@example.com... Sender ok
RCPT To: firstname.lastname@example.org
250 email@example.com... 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
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 */