?
Solved

send mail using sockets

Posted on 2004-09-14
15
Medium Priority
?
247 Views
Last Modified: 2013-12-23
I have a  program in C which uses unix sockets to send mail from server to microsoft exchange client. The mail are sent using the email relay.

If i try HELO.., MAIL FROM.. (manually), it works fine, but when i try the same using the program i get the error 'Timeout occured for client' .

The C program establishes connection and sends data in the order of

1. HELO
2. MAIL FROM: <from emailid>\n
3. RCPT TO: <to emailid>\n
4. DATA ..
..
QUIT

After each step there is a read command to check if the earlier command has completed without errors. My problem is that, the program hangs after step 2 and i get error "451 Timeout waiting for client input" after about 10 minutes.
0
Comment
Question by:kcube
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 2
15 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 12063192
> ..  from server to microsoft exchange client
what exactly is a "microsoft exchange client"?

i.g. you cannot send to a client (MUA) just to a server (MTA). Or did you just use the wrong words?
0
 

Author Comment

by:kcube
ID: 12073282
Iam sorry for the wrong use of words. It should have been communicating to a microsoft exchange server not client. The C program is on a solaris box and it initiates a connection with the microsoft exchange server.
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 1000 total points
ID: 12073379
if exchange operates in a RFC-compliant mode (HELO, MAIL FROM, RCPT TO, etc.) then it should work, you can simply test with:
   telnet exchange-hostname 25
0
Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

 

Author Comment

by:kcube
ID: 12074345
Yes, i have already tried telnet exchange-hostname 25.
The command works fine and iam able to send mails.  

But when i try the same using the program, it does not work. The program establishes a connection to the exchange server and sends the data, but hangs after sending MAIL FROM: value. I am using socket write and read to send the values and receive the output from the exchange server. The write works fine till the MAIL FROM: is sent, but the read command after it hangs. This is the extract from the code which is causing the problem.

..
        sprintf(buf, "HELO\r\n");
        write(fd, buf, strlen(buf));
        read(fd, buf, 256);

        sprintf(buf, "MAIL FROM: <%s>\n", from);
        write(fd, buf, strlen(buf));
        read(fd, buf, 256); /* hangs here */
..

any clues?
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 12076249
>    read(fd, buf, 256);

and you're 300% shure that Exchange does not send more than 256 bytes?
0
 

Author Comment

by:kcube
ID: 12077088
I believe the message would be truncated to 256 bytes. Iam only checking the first 3 chars to see if its 250  ... signifying that no errors have occured
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 12078621
and what does exchange do when it cannot deliver 257 bytes? do you know?
I assume that it closes the connection.
0
 

Author Comment

by:kcube
ID: 12082597
Thanks for your replies. To find the size of data being received, i have tried to use MSG_PEEK in a 'recv' command and checking the return value, instead of 'read'. This also hangs. If i comment out all the read commands, then the program runs through but no email is relayed by exchange server. How can i check the size of data being received in this situation. I have also tried changing the size from 256 to 2048 which is the size of 'buf' variable, but to no avail. Also, is there any way i can get around the size issue.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 12082648
sounds like M$ implemented standards their own way again :-((
Sorry I don't know anything about M$ and its programming, I'd use a tcp/ip sniffer and watch what happens with telnet and then with your programm. The difference in the protocol handshake should point to the problem.
0
 
LVL 62

Expert Comment

by:gheist
ID: 12187922
Basically HELO must have an argument, good exchange tracks standards well
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 12468013
basicaly HELO must not have an argument
I'd vote for PAQ norefund
0
 
LVL 62

Assisted Solution

by:gheist
gheist earned 1000 total points
ID: 12491821
RFC821 3.3 OPENING AND CLOSING
RFC2821 4.1.1.1 Extended HELLO (EHLO) or HELLO (HELO)


maybe you stick to some strong intranet standards which do not apply anywhere else.
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Make the most of your online learning experience.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question