Sponsored Content
Top Forums Programming Help needed for C++ SMTP Client Post 302169102 by andryk on Wednesday 20th of February 2008 09:17:10 AM
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
 

9 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

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. 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

7. 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

8. 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

9. 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
STRCAT(3)						   BSD Library Functions Manual 						 STRCAT(3)

NAME
strcat, strncat -- concatenate strings LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <string.h> char * strcat(char * restrict s, const char * restrict append); char * strncat(char * restrict s, const char * restrict append, size_t count); DESCRIPTION
The strcat() and strncat() functions append a copy of the null-terminated string append to the end of the null-terminated string s, then add a terminating ''. The string s must have sufficient space to hold the result. The strncat() function appends not more than count characters from append, and then adds a terminating ''. RETURN VALUES
The strcat() and strncat() functions return the pointer s. SEE ALSO
bcopy(3), memccpy(3), memcpy(3), memmove(3), strcpy(3), strlcat(3), strlcpy(3), wcscat(3) STANDARDS
The strcat() and strncat() functions conform to ISO/IEC 9899:1990 (``ISO C90''). SECURITY CONSIDERATIONS
The strcat() function is easily misused in a manner which enables malicious users to arbitrarily change a running program's functionality through a buffer overflow attack. Avoid using strcat(). Instead, use strncat() or strlcat() and ensure that no more characters are copied to the destination buffer than it can hold. Note that strncat() can also be problematic. It may be a security concern for a string to be truncated at all. Since the truncated string will not be as long as the original, it may refer to a completely different resource and usage of the truncated resource could result in very incorrect behavior. Example: void foo(const char *arbitrary_string) { char onstack[8]; #if defined(BAD) /* * This first strcat is bad behavior. Do not use strcat! */ (void)strcat(onstack, arbitrary_string); /* BAD! */ #elif defined(BETTER) /* * The following two lines demonstrate better use of * strncat(). */ (void)strncat(onstack, arbitrary_string, sizeof(onstack) - strlen(onstack) - 1); #elif defined(BEST) /* * These lines are even more robust due to testing for * truncation. */ if (strlen(arbitrary_string) + 1 > sizeof(onstack) - strlen(onstack)) err(1, "onstack would be truncated"); (void)strncat(onstack, arbitrary_string, sizeof(onstack) - strlen(onstack) - 1); #endif } BSD
December 1, 2009 BSD
All times are GMT -4. The time now is 11:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy