🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
7 messages
7 total messages Started by Robert G. Hoover Wed, 27 Feb 2008 16:47
porting to Microsoft Exchange
#562
Author: Robert G. Hoover
Date: Wed, 27 Feb 2008 16:47
14 lines
1353 bytes
Hi All,

My apologies if this is off-topic...

I need to write a program that interfaces with Microsoft's Exchange 
email server. I've established communication on standard SMTP port 25 
but I can't find any API definition for the protocol. Does anyone know 
where such a document exists? Or perhaps an example of how to send an 
email using Exchange's API? I think I need to use commands like EHLO, 
etc...?

Many thanks,

Rob
Re: porting to Microsoft Exchange
#566
Author: Alan Bellingham
Date: Wed, 27 Feb 2008 16:50
15 lines
1561 bytes
"Robert G. Hoover" <not.a.real.address@anywhere.sorry> wrote:

>I need to write a program that interfaces with Microsoft's Exchange 
>email server. I've established communication on standard SMTP port 25 
>but I can't find any API definition for the protocol. Does anyone know 
>where such a document exists? Or perhaps an example of how to send an 
>email using Exchange's API? I think I need to use commands like EHLO, 
>etc...?

For SMTP, http://www.rfc.net/rfc2821.html

Alan Bellingham
-- 
Team Browns
ACCU Conference 2008: 2-5 April 2008 - Oxford, UK
Re: porting to Microsoft Exchange
#564
Author: Robert G. Hoover
Date: Wed, 27 Feb 2008 16:59
52 lines
2377 bytes
Hi Alan,

That's exactly what I used to communicate to non-Exchange servers. 
Unfortunately this Exchange server doesn't seem to recognize any of 
those commands... :(

Here's a log excerpt though it doesn't look like much help...


[2008/02/19 15:58:45.219] - "N58050" (149.155.213.204) reading data from 
"nbie2ksrv1.nbi.bbsrc.ac.uk" (149.155.210.12)...

[2008/02/19 15:58:45.219] - 220 NBIE2KSRV1.nbi.bbsrc.ac.uk Microsoft 
ESMTP MAIL Service, Version: 6.0.3790.1830 ready at  Tue, 19 Feb 2008 
15:58:43 +0000

501 5.5.4 Invalid Address

[2008/02/19 15:58:45.219] - exiting TEmailOutForm::ClientSocketRead()...

[2008/02/19 15:58:45.485] - entering TEmailOutForm::ClientSocketRead()...

[2008/02/19 15:58:45.485] - "N58050" (149.155.213.204) reading data from 
"nbie2ksrv1.nbi.bbsrc.ac.uk" (149.155.210.12)...

[2008/02/19 15:58:45.485] - 500 5.3.3 Unrecognized command

500 5.3.3 Unrecognized command

500 5.3.3 Unrecognized command

500 5.3.3 Unrecognized command

500 5.3.3 Unrecognized command

500 5.3.3 Unrecognized command

500 5.3.3 Unrecognized command

500 5.3.3 Unrecognized command

[2008/02/19 15:58:45.485] - exiting TEmailOutForm::ClientSocketRead()...





Alan Bellingham wrote:
> 
> For SMTP, http://www.rfc.net/rfc2821.html
> 
> Alan Bellingham
Re: porting to Microsoft Exchange
#567
Author: Remy Lebeau (TeamB)
Date: Wed, 27 Feb 2008 17:40
23 lines
1734 bytes
"Robert G. Hoover" <not.a.real.address@anywhere.sorry> wrote in message 
news:47c59455@newsgroups.borland.com...

> I've established communication on standard SMTP port
> 25 but I can't find any API definition for the protocol.

There ar plenty of third-party components available that implement the SMTP 
protocol for you.  You don't need to do it manually.

> Does anyone know where such a document exists?

If you really want to implement SMTP manually, then you need to read RFC 
2821 at the very least:

    http://www.ietf.org/rfc/rfc2821.txt

Addition features of SMTP are defined in other RFCs.  Go to 
http://www.rfc-editor.org/rfcsearch.html and search for "SMTP" to see them 
all.


Gambit 
Re: porting to Microsoft Exchange
#569
Author: Remy Lebeau (TeamB)
Date: Wed, 27 Feb 2008 17:43
27 lines
2049 bytes
"Robert G. Hoover" <not.a.real.address@anywhere.sorry> wrote in message 
news:47c596ee$1@newsgroups.borland.com...

> That's exactly what I used to communicate to non-Exchange servers. 
> Unfortunately this Exchange server doesn't seem to recognize any of those 
> commands... :(

Yes, it does.  Exchange supports standard SMTP.

> Here's a log excerpt though it doesn't look like much help...

That log is pretty useless, as it is not showing any of the commands that 
you are sending to the server.  It is only showing the replies.

Please show your actual code, or at least a more complete log that shows 
both sides of the communication.

> [2008/02/19 15:58:45.219] - 220 NBIE2KSRV1.nbi.bbsrc.ac.uk
> Microsoft ESMTP MAIL Service, Version: 6.0.3790.1830 ready at
> Tue, 19 Feb 2008 15:58:43 +0000

That proves that you are communicating with Exchange via SMTP, as you are 
receiving an SMTP greeting from the server.


Gambit 
Re: porting to Microsoft Exchange
#577
Author: Robert G. Hoover
Date: Fri, 29 Feb 2008 13:58
86 lines
3547 bytes
Yea, I completely agree with you guys. It seems to me that I'm talking 
the SMTP talk and for some reason (probably specific to the customer's 
security) my talk is coming back void...

The trouble is that the Exchange server (using "standard SMTP protocol") 
is in the UK and configured not to accept outside requests. I have only 
the log that the customer generated for me. :(

Here's my code... sorry for the formatting... does anything jump out to you?

// send email message to target recipient
bool TEmailOutForm::SendEmailMessage(
AnsiString SenderName,	  // name of sender as "NAME <EMAIL>"
AnsiString SenderEmail,	  // source email address
AnsiString RecipientName, // name of recipient as "NAME <EMAIL>"
AnsiString RecipientEmail,// target email address
AnsiString SubjectText,   // email subject line
AnsiString BodyText)	  // email body contents
{
// compile message
AnsiString MessageContents =
"ehlo ["       + ClientSocket->Socket->LocalAddress    + "]\n"
+ "mail from:" + SenderEmail                           +  "\n"
+ "rcpt to:"   + RecipientEmail                        +  "\n"
+ "data\n"
+ "from:"      + SenderName    + " <" + SenderEmail    + ">\n"
+ "to:"        + RecipientName + " <" + RecipientEmail + ">\n"
+ "subject:"   + SubjectText                           +  "\n";

// append body
MessageContents += BodyText + "\n";

// end message with <CR><LF>.<CR><LF>
MessageContents += String("").sprintf("%c%c.%c%cquit\n", 13, 10, 13, 10);

// send this message to SMTP server
bool SuccessfulTransmit = SendEmailMessageData(MessageContents);
}

If I pair up the communications, I suppose it would look like this...

ehlo [149.155.213.204]

220 NBIE2KSRV1.nbi.bbsrc.ac.uk Microsoft ESMTP MAIL Service, Version: 
6.0.3790.1830 ready at  Tue, 19 Feb 2008 15:58:43 +0000

mail from:myemail@mydomain.com

501 5.5.4 Invalid Address

rcpt to:someone@theirdomain.com

500 5.3.3 Unrecognized command

data

500 5.3.3 Unrecognized command

from:

500 5.3.3 Unrecognized command

to:

500 5.3.3 Unrecognized command

subject:

500 5.3.3 Unrecognized command

0x13 0x10

500 5.3.3 Unrecognized command

0x13

500 5.3.3 Unrecognized command

quit

500 5.3.3 Unrecognized command


Perhaps the sender email address (mine) is not in their whitelist as I 
don't exist in their domain and the server then refuses to recognize 
anything else???
Re: porting to Microsoft Exchange
#580
Author: Remy Lebeau (TeamB)
Date: Fri, 29 Feb 2008 18:31
51 lines
2796 bytes
"Robert G. Hoover" <not.a.real.address@anywhere.sorry> wrote in message 
news:47c80f8b$1@newsgroups.borland.com...

> It seems to me that I'm talking the SMTP talk and for some
> reason (probably specific to the customer's security) my talk
> is coming back void...

Meaning what exactly?  You need to be more specific.

> Here's my code... sorry for the formatting... does anything jump
> out to you?

Well, for one thing, you are doing everything manually instead of using an 
actual SMTP component.  You are not implementing the SMTP protocol even 
remotely correct at all.  You are sending all of your commands as one big 
string, which is the wrong way to handle SMTP.  You are using "\n" for every 
line break between commands when you need to use "\r\n" instead.  And you 
are not processing any of the SMTP replies at all.

I strongly suggest you drop your code altogether and use a real SMTP 
component instead, such as from Indy or ICS.  Let it do all of the low-level 
work for you.

> If I pair up the communications, I suppose it would look like this...

Almost.  You have to wait for the greeting to arrive before sending the EHLO 
command, which will have its own reply (that you have not shown).

> mail from:myemail@mydomain.com

You need to enclose email addresses in angle brackets:

    mail from:<myemail@mydomain.com>

    rcpt to:<someone@theirdomain.com>

> data
>
> 500 5.3.3 Unrecognized command
>
> from:
>
> 500 5.3.3 Unrecognized command
<snip>

Everything after the DATA command is arbitrary message text.  It is not a 
series of SMTP commands.


Gambit 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads