Help needed for C++ SMTP Client


 
Thread Tools Search this Thread
Top Forums Programming Help needed for C++ SMTP Client
# 1  
Old 02-15-2008
Help needed for C++ SMTP Client

Hi, may i know how do i take in user inputs and set them for "Subject", "To" and "From"?
===
my code:
write(sockfd,"DATA\r\n",strlen("DATA\r\n"));
strcpy (msgToSvr, "");
cin.getline(body, 99, '\n');
strcat (msgToSvr, subject);
strcat (msgToSvr, "\r\n");
write(sockfd,msgToSvr,strlen(msgToSvr));
strcpy (msgToSvr, "");
cin.getline(body, 99, '\n');
strcat (msgToSvr, from);
strcat (msgToSvr, "\r\n");
write(sockfd,msgToSvr,strlen(msgToSvr));
strcpy (msgToSvr, "");
cin.getline(body, 99, '\n');
strcat (msgToSvr, to);
strcat (msgToSvr, "\r\n");
write(sockfd,msgToSvr,strlen(msgToSvr));
write(sockfd,"\r\n",strlen("\r\n"));

===

char subject[100], from[100], to[100] are all input from user.

however when i check my mail.. the subject, from, and to are in my message body. They should not be in the body..

right now i'm getting
===
Subject: Hello
From: John
To: Peter
===

in the body.

how do i get the user inputs and assign them to the proper places?
# 2  
Old 02-20-2008
Quote:
Originally Posted by blurboy
Hi, may i know how do i take in user inputs and set them for "Subject", "To" and "From"?
===
my code:
write(sockfd,"DATA\r\n",strlen("DATA\r\n"));
strcpy (msgToSvr, "");
cin.getline(body, 99, '\n');
strcat (msgToSvr, subject);
strcat (msgToSvr, "\r\n");
write(sockfd,msgToSvr,strlen(msgToSvr));
strcpy (msgToSvr, "");
cin.getline(body, 99, '\n');
strcat (msgToSvr, from);
strcat (msgToSvr, "\r\n");
write(sockfd,msgToSvr,strlen(msgToSvr));
strcpy (msgToSvr, "");
cin.getline(body, 99, '\n');
strcat (msgToSvr, to);
strcat (msgToSvr, "\r\n");
write(sockfd,msgToSvr,strlen(msgToSvr));
write(sockfd,"\r\n",strlen("\r\n"));

===

char subject[100], from[100], to[100] are all input from user.

however when i check my mail.. the subject, from, and to are in my message body. They should not be in the body..

right now i'm getting
===
Subject: Hello
From: John
To: Peter
===

in the body.

how do i get the user inputs and assign them to the proper places?
Hi, the data command is after all the headers ... you're all kidding right ? Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

Help needed in my client/server app - Delay in displaying messages from clients.

Ok so this is what I have. I have separate client and server codes. I initially had the server listening and accepting connections from ONE port, and it was working great. Now, what I want to do is, enable the server to listen and accept connections on TWO OR MORE ports , thus, effectively... (2 Replies)
Discussion started by: CrazedMonk
2 Replies

2. HP-UX

SMTP and NTLM

Hi, I have a HP Unix from which I'm trying to connect to an email server through telnet and test sending emails using commands. Why am I doing that is not important. The email server is an Exchange server and it looks like that the only Authentication method it supports is NTLM. The host name... (0 Replies)
Discussion started by: gheibia
0 Replies

3. Red Hat

SMTP Settings

Hi all, Please help to check weather the SMTP settings are configured or not on my LINUX server? I want to send a mail to mailbox. I know that the target SMTP server has to be configured on LINUX box to do so. How can i see weather it is configured or not? --Ramesh Ch. (3 Replies)
Discussion started by: Raamc
3 Replies

4. UNIX for Dummies Questions & Answers

Smtp

Hi All, I have a unix box which is in a network with windows machine, I am able to send the mails to the user id's with in the unix box. I dont have Internet connection for this box, so I am not able to test if it can send mails to external network or not? I want to know, if SMTP is already... (1 Reply)
Discussion started by: balu_puttaganti
1 Replies

5. Programming

Client/Server Socket Application - Preventing Client from quitting on server crash

Problem - Linux Client/Server Socket Application: Preventing Client from quitting on server crash Hi, I am writing a Linux socket Server and Client using TCP protocol on Ubuntu 9.04 x64. I am having problem trying to implement a scenario where the client should keep running even when the... (2 Replies)
Discussion started by: varun.nagpaal
2 Replies

6. Programming

SMTP mail client C++

Hey Guys, I am writing an SMTP mail client in c++ in unix and it needs to do the following: I need to create a client the client talks to port 25 it sends a hello world message I also need to support and smtpclient class and a clientdriver class I have written the smtpclient class, but I... (1 Reply)
Discussion started by: jcy8096
1 Replies

7. Solaris

SMTP Configuration

Hello everyone, I've got this Java script which needs to know the SMTP host in order to send out mails from a particular mail ID. But I have no idea how or what to configure in SMTP for getting this code up and running.(All I know is SMTP=Simple Mail Transfer Protocol). I'm using Solaris 5.8.... (1 Reply)
Discussion started by: Rajat
1 Replies

8. Programming

C Smtp

how do you send a ".\n" in a smtp client? >354 Send message, end with <CRLF>.<CRLF> >. > i have already issued a "./n" but it doesnt work. please help. thanks. (1 Reply)
Discussion started by: grotesque
1 Replies

9. UNIX for Advanced & Expert Users

Smtp

Hi All, I am running an email server on a Linux machine. My goal is to set up in a way that I can use pop3 to retrieve mail from a Windows machine using Outlook. Now I can download the messages from the Linux email server, however I can not send out messages. I encounter this error: ... (1 Reply)
Discussion started by: vtran4270
1 Replies
Login or Register to Ask a Question