EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

How to send mail from Gmail SMTP server ?

Started by kara_liao February 25, 2010
Here is the SMTP.C sample from Rabbit.com, I had applied to gmail account from
Google, ID: karagigabyte.gmail.com and password: 12345678 (just a example), I
would like to send a mail via the Google SMTP Server to
kara_liao@...

There was no any mail from RCM3000 when I checked my mail from
kara_liao@..., please help me, why ?
#class auto
#define TCPCONFIG 1
#define FROM "karagigabyte@..."
#define TO "kara_liao@..."
#define SUBJECT "You've got mail!"
#define BODY "Visit the Rabbit Semiconductor web site.\r\n" \
"There you'll find the latest news about Dynamic C."
#define SMTP_SERVER "smtp.gmail.com"
#define SMTP_DOMAIN "smtp.gmail.com"
#define SMTP_VERBOSE
#define USE_SMTP_AUTH
#define SMTP_AUTH_FAIL_IF_NO_AUTH

#memmap xmem
#use dcrtcp.lib
#use smtp.lib

void main()
{
// Start network and wait for interface to come up (or error exit).
sock_init_or_exit(1);

#ifdef USE_SMTP_AUTH
smtp_setauth ("karagigabyte@...", "12345678");
#endif

smtp_sendmail(TO, FROM, SUBJECT, BODY);

while(smtp_mailtick()==SMTP_PENDING)
continue;

if(smtp_status()==SMTP_SUCCESS)
printf("Message sent\n");
else
printf("Error sending message\n");
}

In addition to authentication, Google requires the use of TLS (Transport Layer Security). I do not know if Rabbit supports this. Perhaps there is another group member who can help with TLS.

Also, look at the status returned by smtp_status() to help determine why the SMTP is failing.

--- In r..., "kara_liao" wrote:
>
> Here is the SMTP.C sample from Rabbit.com, I had applied to gmail account from
> Google, ID: karagigabyte.gmail.com and password: 12345678 (just a example), I
> would like to send a mail via the Google SMTP Server to
> kara_liao@
>
> There was no any mail from RCM3000 when I checked my mail from
> kara_liao@, please help me, why ?
> #class auto
> #define TCPCONFIG 1
> #define FROM "karagigabyte@"
> #define TO "kara_liao@"
> #define SUBJECT "You've got mail!"
> #define BODY "Visit the Rabbit Semiconductor web site.\r\n" \
> "There you'll find the latest news about Dynamic C."
> #define SMTP_SERVER "smtp.gmail.com"
> #define SMTP_DOMAIN "smtp.gmail.com"
> #define SMTP_VERBOSE
> #define USE_SMTP_AUTH
> #define SMTP_AUTH_FAIL_IF_NO_AUTH
>
> #memmap xmem
> #use dcrtcp.lib
> #use smtp.lib
>
> void main()
> {
> // Start network and wait for interface to come up (or error exit).
> sock_init_or_exit(1);
>
> #ifdef USE_SMTP_AUTH
> smtp_setauth ("karagigabyte@", "12345678");
> #endif
>
> smtp_sendmail(TO, FROM, SUBJECT, BODY);
>
> while(smtp_mailtick()==SMTP_PENDING)
> continue;
>
> if(smtp_status()==SMTP_SUCCESS)
> printf("Message sent\n");
> else
> printf("Error sending message\n");
> }
>

I am not an email expert, but, I think you should add the string below to the start of the body. This helps the mail server know how to interpret the text.

"MIME-Version: 1.0\r\nContent-Type: TEXT/PLAIN;charset=US-ASCII\r\n\r\n"

The next release of Dynamic C is supposed to include TLS client support, and I think there's even a sample that demonstrates sending mail through Google's GMail.

You might be able to contact your sales rep or tech support at Rabbit if you can't wait until the next release.

-Tom
On Feb 25, 2010, at 6:31 AM, kev99franz wrote:
> In addition to authentication, Google requires the use of TLS (Transport Layer Security). I do not know if Rabbit supports this. Perhaps there is another group member who can help with TLS.

The 2024 Embedded Online Conference