Reply by Dave Moore September 22, 20102010-09-22
I would get a hub, route packets to another machine running wireshark. You'll see the entire conversation and be able to figure a bit more out I think.

From: r... [mailto:r...] On Behalf Of Steve Trigero
Sent: Monday, September 20, 2010 11:34 AM
To: r...
Subject: Re: [rabbit-semi] Re: SMTP Implementation

Ok, I'm back on this issue again. I added authorization, and smtp_setauth() returns

with no error. Yet I am still unable to send an email. I keep getting SMTP_UNEXPECTED

error.

The verbose SMTP printout follows. Is there a clue here about what I am doing wrong?

(the "case" lines are my added printf statements in the state machine in smtp_mailtick())

SMTP: Case SMTP_PARSE_EHLO
SMTP: Case SMTP_PARSE_EHLO
SMTP: Case SMTP_PARSE_EHLO
SMTP: Case SMTP_PARSE_EHLO
SMTP: Case SMTP_PARSE_EHLO
SMTP: Case SMTP_PARSE_EHLO
SMTP: Case SMTP_PARSE_EHLO
SMTP: Read: 25à¥
SMTP: Case SMTP_SEND_AUTH
SMTP: Case SMTP_WAIT_CHALLENGE
SMTP: Read: 250-SIZE
SMTP: Wrote 42 bytes, 250-SIZE
SMTP: Case SMTP_WAITFORRCPT250
SMTP: Read: 250-PIPELINING
SMTP: Case SMTP_WAITFORRCPT250
SMTP: Read: 250-DSN
SMTP: Case SMTP_WAITFORRCPT250
SMTP: Read: 250-ENHANCEDSTATUSCODES
SMTP: Case SMTP_WAITFORRCPT250
SMTP: Read: 250-STARTTLS
SMTP: Case SMTP_WAITFORRCPT250
SMTP: Read: 250-X-ANONYMOUSTLS
SMTP: Case SMTP_WAITFORRCPT250
SMTP: Read: 250-AUTH NTLM
SMTP: Case SMTP_WAITFORRCPT250
SMTP: Read: 250-X-EXPS GSSAPI NTLM
SMTP: Case SMTP_WAITFORRCPT250
SMTP: Read: 250-8BITMIME
SMTP: Case SMTP_WAITFORRCPT250
SMTP: Case SMTP_WAITFORRCPT250
SMTP: Case SMTP_WAITFORRCPT250
SMTP: Case SMTP_WAITFORRCPT250
SMTP: Case SMTP_WAITFORRCPT250
SMTP: Case SMTP_WAITFORRCPT250
...
SMTP: Read:
SMTP: Case SMTP_DONE/ERROR: 14
SMTP: Socket unexpectedly closed!

_____

From: Steve Trigero
To: r...
Sent: Wed, September 8, 2010 12:52:51 PM
Subject: Re: [rabbit-semi] Re: SMTP Implementation

2 questions:
1. Is the "username" argument of smtp_setauth() supposed to be an email address as opposed to a login/ID name?

2. Are you supposed to call smtp_setauth() everytime you need to send an email? In other words, can I call it

just once at initialization?

Steve

_____

From: ebrains2003
To: r...
Sent: Wed, September 8, 2010 11:52:19 AM
Subject: [rabbit-semi] Re: SMTP Implementation

> So, does all this mean that it's telling me I need to use Authentication?
> Â
> Steve

Sure looks that way. This is the email routine I used. It has worked very well and I had USE_SMTP_AUTH defined to enable authorization. I believe I was using DC 9.25 back then:

int HandleEmail(void)
{
// smtp_setauth("u...@domain.com ", "password");
#ifdef USE_SMTP_AUTH
smtp_setauth (EmailFrom, EmailPass);
#endif
smtp_sendmail(EmailAddress, EmailFrom, subject, body);

while(smtp_mailtick()==SMTP_PENDING)
continue;

if(smtp_status()==SMTP_SUCCESS)
{
#ifdef IPIO_DEBUG
printf("Message sent\n");
#endif
PorteOn(STAT_GREEN);
PorteOff(STAT_RED);
return 1;// 1 indicates success
}
else
{
#ifdef IPIO_DEBUG
printf("Error sending message\n");
#endif
PorteOn(STAT_RED);
PorteOff(STAT_GREEN);
// PortaOn(EMAIL_RED);
return 0;// 0 indicates an error
}
}
Reply by Steve Trigero September 21, 20102010-09-21
Ok, I'm back on this issue again.  I added authorization, and smtp_setauth()
returns

with no error. Yet I am still unable to send an email. I keep getting
SMTP_UNEXPECTED

error.

The verbose SMTP printout follows. Is there a clue here about what I am doing
wrong?
(the "case" lines are my added printf statements in the state machine in
smtp_mailtick())

SMTP: Case SMTP_PARSE_EHLO                                                     
SMTP: Case SMTP_PARSE_EHLO                                                     
SMTP: Case SMTP_PARSE_EHLO                                                     
SMTP: Case SMTP_PARSE_EHLO                                                     
SMTP: Case SMTP_PARSE_EHLO                                                     
SMTP: Case SMTP_PARSE_EHLO                                                     
SMTP: Case SMTP_PARSE_EHLO                                                     
SMTP: Read: 25ॠ                                                              
SMTP: Case SMTP_SEND_AUTH                                                      
SMTP: Case SMTP_WAIT_CHALLENGE                                                 
SMTP: Read: 250-SIZE                                                           
SMTP: Wrote 42 bytes, 250-SIZE                                                 
SMTP: Case SMTP_WAITFORRCPT250                                                 
SMTP: Read: 250-PIPELINING                                                     
SMTP: Case SMTP_WAITFORRCPT250                                                 
SMTP: Read: 250-DSN                                                            
SMTP: Case SMTP_WAITFORRCPT250                                                 
SMTP: Read: 250-ENHANCEDSTATUSCODES                                            
SMTP: Case SMTP_WAITFORRCPT250                                                 
SMTP: Read: 250-STARTTLS                                                       
SMTP: Case SMTP_WAITFORRCPT250                                                 
SMTP: Read: 250-X-ANONYMOUSTLS                                                 
SMTP: Case SMTP_WAITFORRCPT250                                                 
SMTP: Read: 250-AUTH NTLM                                                      
SMTP: Case SMTP_WAITFORRCPT250                                                 
SMTP: Read: 250-X-EXPS GSSAPI NTLM                                             
SMTP: Case SMTP_WAITFORRCPT250                                                 
SMTP: Read: 250-8BITMIME                                                       
SMTP: Case SMTP_WAITFORRCPT250                                                 
SMTP: Case SMTP_WAITFORRCPT250                                                 
SMTP: Case SMTP_WAITFORRCPT250                                                 
SMTP: Case SMTP_WAITFORRCPT250                                                 
SMTP: Case SMTP_WAITFORRCPT250                                                 
SMTP: Case SMTP_WAITFORRCPT250                                                 
...
SMTP: Read:                                                                    
SMTP: Case SMTP_DONE/ERROR: 14                                                 
SMTP: Socket unexpectedly closed!                                              
 

________________________________
From: Steve Trigero
To: r...
Sent: Wed, September 8, 2010 12:52:51 PM
Subject: Re: [rabbit-semi] Re: SMTP Implementation

 
2 questions:

1. Is the "username" argument of smtp_setauth() supposed to be an email address
as opposed to a login/ID name?

2. Are you supposed to call smtp_setauth() everytime you need to send an email?
In other words, can I call it
    just once at initialization?

Steve

________________________________
From: ebrains2003
To: r...
Sent: Wed, September 8, 2010 11:52:19 AM
Subject: [rabbit-semi] Re: SMTP Implementation

 
> So, does all this mean that it's telling me I need to use Authentication?
>  
> Steve

Sure looks that way. This is the email routine I used. It has worked very well
and I had USE_SMTP_AUTH defined to enable authorization. I believe I was using
DC 9.25 back then:

int HandleEmail(void)
{
// smtp_setauth("u...@domain.com", "password");
#ifdef USE_SMTP_AUTH
smtp_setauth (EmailFrom, EmailPass);
#endif
smtp_sendmail(EmailAddress, EmailFrom, subject, body);

while(smtp_mailtick()==SMTP_PENDING)
continue;

if(smtp_status()==SMTP_SUCCESS)
{
#ifdef IPIO_DEBUG
printf("Message sent\n");
#endif
PorteOn(STAT_GREEN);
PorteOff(STAT_RED);
return 1;// 1 indicates success
}
else
{
#ifdef IPIO_DEBUG
printf("Error sending message\n");
#endif
PorteOn(STAT_RED);
PorteOff(STAT_GREEN);
// PortaOn(EMAIL_RED);
return 0;// 0 indicates an error
}
}
Reply by Per-Olof Bergström September 8, 20102010-09-08
I use gmail.com and use my emai address to login.
I only call smtp_setauth()  once at init.

pob

________________________________
From: Steve Trigero
To: r...
Sent: Wed, September 8, 2010 9:52:51 PM
Subject: Re: [rabbit-semi] Re: SMTP Implementation

 
2 questions:

1. Is the "username" argument of smtp_setauth() supposed to be an email address
as opposed to a login/ID name?

2. Are you supposed to call smtp_setauth() everytime you need to send an email?
In other words, can I call it
    just once at initialization?

Steve

________________________________
From: ebrains2003
To: r...
Sent: Wed, September 8, 2010 11:52:19 AM
Subject: [rabbit-semi] Re: SMTP Implementation

 
> So, does all this mean that it's telling me I need to use Authentication?
>  
> Steve

Sure looks that way. This is the email routine I used. It has worked very well
and I had USE_SMTP_AUTH defined to enable authorization. I believe I was using
DC 9.25 back then:

int HandleEmail(void)
{
// smtp_setauth("u...@domain.com", "password");
#ifdef USE_SMTP_AUTH
smtp_setauth (EmailFrom, EmailPass);
#endif
smtp_sendmail(EmailAddress, EmailFrom, subject, body);

while(smtp_mailtick()==SMTP_PENDING)
continue;

if(smtp_status()==SMTP_SUCCESS)
{
#ifdef IPIO_DEBUG
printf("Message sent\n");
#endif
PorteOn(STAT_GREEN);
PorteOff(STAT_RED);
return 1;// 1 indicates success
}
else
{
#ifdef IPIO_DEBUG
printf("Error sending message\n");
#endif
PorteOn(STAT_RED);
PorteOff(STAT_GREEN);
// PortaOn(EMAIL_RED);
return 0;// 0 indicates an error
}
}
Reply by ebrains2003 September 8, 20102010-09-08
> 2 questions:
>
> 1. Is the "username" argument of smtp_setauth() supposed to be an email address
> as opposed to a login/ID name?
That may depend on the email server. Mine requires a full email address for a username.

> 2. Are you supposed to call smtp_setauth() everytime you need to send an email?
> In other words, can I call it
>     just once at initialization?
I made it part of the function, so it was always called in my program. I guess you could try calling it just once, but what is the harm in calling it each time? I had up to two email users that could be emailed by this particular product, so it needed to be set those fields each time.

Reply by Steve Trigero September 8, 20102010-09-08
2 questions:

1. Is the "username" argument of smtp_setauth() supposed to be an email address
as opposed to a login/ID name?

2. Are you supposed to call smtp_setauth() everytime you need to send an email?
In other words, can I call it
    just once at initialization?

Steve

________________________________
From: ebrains2003
To: r...
Sent: Wed, September 8, 2010 11:52:19 AM
Subject: [rabbit-semi] Re: SMTP Implementation

 
> So, does all this mean that it's telling me I need to use Authentication?
>  
> Steve

Sure looks that way. This is the email routine I used. It has worked very well
and I had USE_SMTP_AUTH defined to enable authorization. I believe I was using
DC 9.25 back then:

int HandleEmail(void)
{
// smtp_setauth("u...@domain.com", "password");
#ifdef USE_SMTP_AUTH
smtp_setauth (EmailFrom, EmailPass);
#endif
smtp_sendmail(EmailAddress, EmailFrom, subject, body);

while(smtp_mailtick()==SMTP_PENDING)
continue;

if(smtp_status()==SMTP_SUCCESS)
{
#ifdef IPIO_DEBUG
printf("Message sent\n");
#endif
PorteOn(STAT_GREEN);
PorteOff(STAT_RED);
return 1;// 1 indicates success
}
else
{
#ifdef IPIO_DEBUG
printf("Error sending message\n");
#endif
PorteOn(STAT_RED);
PorteOff(STAT_GREEN);
// PortaOn(EMAIL_RED);
return 0;// 0 indicates an error
}
}
Reply by ebrains2003 September 8, 20102010-09-08
> So, does all this mean that it's telling me I need to use Authentication?
>  
> Steve

Sure looks that way. This is the email routine I used. It has worked very well and I had USE_SMTP_AUTH defined to enable authorization. I believe I was using DC 9.25 back then:

int HandleEmail(void)
{
// smtp_setauth("u...@domain.com", "password");
#ifdef USE_SMTP_AUTH
smtp_setauth (EmailFrom, EmailPass);
#endif
smtp_sendmail(EmailAddress, EmailFrom, subject, body);

while(smtp_mailtick()==SMTP_PENDING)
continue;

if(smtp_status()==SMTP_SUCCESS)
{
#ifdef IPIO_DEBUG
printf("Message sent\n");
#endif
PorteOn(STAT_GREEN);
PorteOff(STAT_RED);
return 1;// 1 indicates success
}
else
{
#ifdef IPIO_DEBUG
printf("Error sending message\n");
#endif
PorteOn(STAT_RED);
PorteOff(STAT_GREEN);
// PortaOn(EMAIL_RED);
return 0;// 0 indicates an error
}
}

Reply by Steve Trigero September 8, 20102010-09-08
I solved the Virtual Watchdog Timeout by adding a watchdog reset to my loop:

    smtp_sendmail( email_adrs, email_adrs , id_string, buf );
    errCode = smtp_mailtick();
    while ( errCode == SMTP_PENDING ) {
      errCode = smtp_mailtick();
      ScratchDog();
    }

With the watchdog taken care of, it still doesn't work.

So I found the following statement in SMTP.LIB.:

printf("SMTP: Wrote %*.*s",rc, rc, buffer);

That statement looks funny to me. The format statements don't match the number
of
arguments passed. So I replaced it with my own:

printf("SMTP: Wrote %d bytes, %s",rc, buffer);

This is the verbose printout:

SMTP: Opening to 0A0A00B9:25 
SMTP: Connected
SMTP: Read: 220 CMDCEXCAHT01.comtechtel.com Microsoft ESMTP MAIL Service ready a
t Wed, 8 Sep 2010 11:21:48 -0400
SMTP: Wrote 18 bytes, HELO 10.250.5.51
SMTP: Read: 250 CMDCEXCAHT01.comtechtel.com Hello [10.250.5.51]                
SMTP: Wrote 42 bytes, MAIL FROM:                  

What I think this is telling me is that my original email message is not being
sent.

Next I added more printf() statements to track the path through the library. In
function smtp_mailtick()
there is a very large switch statement. So I added a printf() statement at the
beginning of each case
identifying the case. This is printout:

                                                                               
SMTP: Case SMTP_INIT 
SMTP: Opening to 0A0A00B9:25 
SMTP: Case SMTP_WAITFORESTAB  
SMTP: Case SMTP_WAITFORESTAB  
SMTP: Case SMTP_WAITFORESTAB 
SMTP: Case SMTP_WAITFORESTAB 
SMTP: Case SMTP_WAITFORESTAB 
SMTP: Case SMTP_WAITFORESTAB  
SMTP: Case SMTP_WAITFORESTAB 
SMTP: Case SMTP_WAITFORESTAB 
SMTP: Connected 
SMTP: Case SMTP_WAITFORHELO220 
SMTP: Case SMTP_WAITFORHELO220 
SMTP: Case SMTP_WAITFORHELO220
SMTP: Case SMTP_WAITFORHELO220 
SMTP: Read: 220 CMDCEXCAHT01.comtechtel.com Microsoft ESMTP MAIL Service ready a
t Wed, 8 Sep 2010 11:45:08 -0400 
SMTP: Wrote 18 bytes, HELO 10.250.5.51
SMTP: Case SMTP_WAITFORMAIL250
SMTP: Case SMTP_WAITFORMAIL250
SMTP: Case SMTP_WAITFORMAIL250 
SMTP: Case SMTP_WAITFORMAIL250 
SMTP: Case SMTP_WAITFORMAIL250
SMTP: Read: 250 CMDCEXCAHT01.comtechtel.com Hello [10.250.5.51] 
SMTP: Wrote 42 bytes, MAIL FROM:  
SMTP: Case SMTP_WAITFORRCPT250 
SMTP: Case SMTP_WAITFORRCPT250
SMTP: Case SMTP_WAITFORRCPT250
...
several hundred more Case SMTP_WAITFORRCPT250 statements...
...
SMTP: Case SMTP_WAITFORRCPT250 
SMTP: Case SMTP_WAITFORRCPT250
SMTP: Case SMTP_WAITFORRCPT250
SMTP: Read: 53ॠ€7.1 Client was not authenticated 
SMTP: Case SMTP_DONE/ERROR: 14

The last two cases execute the same code, which seems odd to me, since one
case is DONE and the other case is ERROR. The number 14 in the printout is
the value of the case, which is SMTP_ERROR.

So, does all this mean that it's telling me I need to use Authentication?
 
Steve

 

________________________________
From: Tom Collins
To: r...
Sent: Wed, September 8, 2010 9:04:22 AM
Subject: Re: [rabbit-semi] Re: SMTP Implementation

 
On Sep 7, 2010, at 4:48 PM, Steve Trigero wrote:
 
>My complaint is
>that the SMTP manual says nothing about it requiring a tcp buffer. And none of
>the smtp api functions
>returns an error indicating the problem encountered.

Certainly a valid complaint about the manual not documenting the need for an
additional TCP socket/buffer for use by the library, but if you check the
documentation for smtp_mailtick, you'll see that it can return SMTP_NOSOCK if it
can't open a network socket.  There are other errors as well, but the sample
doesn't demonstrate checking the final return value of smtp_mailtick().

 My message is 64-bytes, and the subject is around 32-bytes. Are those short or
moderate lengths? 

Sounds short to me...  Another poster described the hard limit of 32KB (signed
16-bit integer).

I'm in the process of modifying smtp.lib so I can try to find where it's getting
hung up. Any ideas on where I
>should look?

Maybe set a breakpoint right after it prints the message saying the email was
sent, and step through the code from that point.  Or sprinkle printfs after that
point to see how far it gets.

-Tom
Reply by Alexandre Kremer September 8, 20102010-09-08
The 19 is actually in hex base, which is 25 decimal ;)It´s right. Does the smtp server you are using to test does the connections on port 25 decimal? It may be using another port. At this time, i really don´t know what´s the problem there. I used this smtp thing on several products with no issues at all.
--- Em ter, 7/9/10, Steve Trigero escreveu:

De: Steve Trigero
Assunto: Re: [rabbit-semi] Re: SMTP Implementation
Para: r...
Data: Terça-feira, 7 de Setembro de 2010, 19:05

 

I switched to DC 9.62 to see if that would make a difference. There is a difference, but it's not
a better difference.
 
This is what SMTP_VERBOSE produces:
 
                                                                               
to:bf93                                                                        

from:bf93                                                                      
subject:bfdc                                                                   

message:1F94                                                                   
SMTP: Opening to A0A00B9:19                                                    
Error opening
socket.                                                          
 
 
The "to", "from", "subject", and "message" parameters appear to be pointers. And I verified the content of those strings
in my code, so I'm sure if what's going on with verbose. But also notice that the mail port is 19. What the....?
I compiled my code "as is". There were no changes made to go to DC 9.62 from 9.25. My code doesn't set
the mail port, it uses the default port, which was supposed to be 25, as it was with DC 9.25.

Also note that, because of all the discussion as to whether a "From" address was required or not,  I set the "From"
address to be the same as the "To" address. So "From" is set with a valid address.
 
In any case, I see no improvement in going with DC 9.62. And one could make the case that going to 9.62 is a
step backwards.
 
Steve

 
From: Tom Collins
To: r...
Sent: Tue, September 7, 2010 6:30:28 AM
Subject: Re: [rabbit-semi] Re: SMTP Implementation

 
On Sep 7, 2010, at 5:12 AM, ebrains2003 wrote:
Make sure the server isn't one that requires POP3 before SMPT, in other words, they won't let you send an email until you first login and read emails (or at least check for new emails). This isnt' all that common, but if you happen to be on one of these servers, it can be tricky. I believe they log your IP address and set a timer. Once you read an email, you have x number of minutes to send emails from that IP address.
POP-before-SMTP is typically for supporting legacy clients.  All SMTP servers in this day and age use authentication (SMTP AUTH) and it's probably the best way to go.  Rabbit has supported SMTP AUTH since one of the early DC 9 releases.
You may also want to allow customers to configure the outbound SMTP port.  It defaults to 25, but many servers will also accept email on port 587 (tcp/submission) as a way to get around ISPs that block direct connections to port 25 (or what to force you to use their SMTP server).
Finally, Google's Gmail service requires that you use TLS (encryption) for your SMTP connections.  Dynamic C just started supporting client-side TLS in a recent DC 10 release, and I believe it includes samples that demonstrate sending email through a Gmail account.
I'd definitely follow ebrains2003's advice and provide a configuration screen in your app, with all of the fields you'd expect to see in an email client like Outlook.

-Tom
Reply by Tom Collins September 8, 20102010-09-08
On Sep 7, 2010, at 4:48 PM, Steve Trigero wrote:
> My complaint is
> that the SMTP manual says nothing about it requiring a tcp buffer. And none of the smtp api functions
> returns an error indicating the problem encountered.

Certainly a valid complaint about the manual not documenting the need for an additional TCP socket/buffer for use by the library, but if you check the documentation for smtp_mailtick, you'll see that it can return SMTP_NOSOCK if it can't open a network socket. There are other errors as well, but the sample doesn't demonstrate checking the final return value of smtp_mailtick().

> My message is 64-bytes, and the subject is around 32-bytes. Are those short or moderate lengths?

Sounds short to me... Another poster described the hard limit of 32KB (signed 16-bit integer).

> I'm in the process of modifying smtp.lib so I can try to find where it's getting hung up. Any ideas on where I
> should look?

Maybe set a breakpoint right after it prints the message saying the email was sent, and step through the code from that point. Or sprinkle printfs after that point to see how far it gets.

-Tom

>
Reply by ebrains2003 September 8, 20102010-09-08
--- In r..., Steve Trigero wrote:
> But also notice that
> the mail port is 19. What the....?

Steve, that is in hex. 0x19 = 25.