Solved

send mail using sockets

Posted on 2004-09-14
15
245 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 250 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
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 

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

Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

Question has a verified solution.

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

Suggested Solutions

Data center, now-a-days, is referred as the home of all the advanced technologies. In-fact, most of the businesses are now establishing their entire organizational structure around the IT capabilities.
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…
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…

737 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