[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

send mail using sockets

Posted on 2004-09-14
15
Medium Priority
?
248 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

When you try to share a printer , you may receive one of the following error messages. Error message when you use the Add Printer Wizard to share a printer: Windows could not share your printer. Operation could not be completed (Error 0x000006…
Most of the applications these days are on Cloud. Cloud is ubiquitous with many service providers in the market. Since it has many benefits such as cost reduction, software updates, remote access, disaster recovery and much more.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

650 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