EmbeddedRelated.com
Forums

SMTP Implementation

Started by seecwriter September 1, 2010
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
}
}