I'm writing a program that will send mail through an smtp server. I can send the commands fine by themselves but when I try to send them with user input (like asking for the desintation addr instead of hard coding it) I have problems.
I want the output to look like
MAIL From:<[email protected]>
RCPT TO:<[email protected]>
Here is my output and below is the relevant code, if anyone could help it would be much appreciated. Thanks
Output
Code:
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <strings.h>
#define SIZE sizeof (struct sockaddr_in)
main ( int argc, char *argv[] )
{
int sockfd, i;
char *fromer;
char helo[] = "HELO \n";
char kara[] = "MAIL From:<\n";
char to[] = "RCPT To:<";
char return_val[1024];
char input[1024];
char c, rc;
struct sockaddr_in server;
if (argc!=2 || argc>2){
printf("Correct syntax is 'usermail <recipient>'\n");
exit(1);
}
strcat(to,argv[1]);
strcat(to,">\n");
printf("(From) :");
gets(fromer);
strcat(kara,fromer);
strcat(kara,">\n");
printf("%s\n",to);
printf("Next is..\n");
printf("%s\n",kara);