473,386 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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?
Feb 15 '08 #1
1 1787
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?

you need to communicate with SMTP server as follows

helo "server name"
mail from: <mailid>
recpt to: <mailid1>
rcpt to: <maild2>
data
subjact: subject line

body message
. <------- must

all lines even empty line has to endup with \n\r.
Regards,
Arul
Feb 15 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: James Hong | last post by:
Help please, I try to sending an email from my html page using the java applet. but it give error on most of the PC only very few work, what is the error i make the java applet show as below ...
2
by: Mark Carter | last post by:
I'm trying to create a mail server in Twisted. I either get SMTPSenderRefused or SMTPException: SMTP AUTH extension not supported by server. What do I need to do to get it to work?
21
by: Nancy | last post by:
Hi, Guys, Is there any other way to use python or mod_python writing a web page? I mean, not use "form.py/email", no SMTP server. <form action="form.py/email" method="POST"> ... Thanks a lot. ...
1
by: Cyndia A. | last post by:
Need ur Help on the following. In my ASP.Net (with C#) Application, I am sending a mail to all newly registered users. I am using System.Web.Mail Package. Can u please guide me how to sort...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
5
by: Sin Jeong-hun | last post by:
Hi. I would like to let users send bug reports or other messages to me. Maybe the easiest way to send e-mails from my application is just use the default e-mail agent by executing a link...
1
by: dansuthar | last post by:
Hi everyone there, I want some help in sending mails using .net 2.0 form vb.net. i use the following code to send SMTP Mails: Code:Dim client As New Net.Mail.SmtpClient("smtp.gmail.com") Dim mm...
1
by: tshad | last post by:
I have a W2K3 Server we are setting up to run a Windows Service for a client at their location. I don't want this machine to go through exchange or their local mail server, I just want the...
4
by: Brian | last post by:
Hello all, we don't actually host our own server but still should work the same. Here is the error message i get "error mailbox unavailable. The server response was: must be authenticated code...
2
by: btcoder | last post by:
Hi, my jsp page uses sun.net.smtp.SmtpClient to send email. It worked fine until the hosted location was moved to another server. Now it generates the sun.net.smtp.SmtpProtocolException and the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.