Anybody use SMTP to send an email successfully?
I would like to send a simple text email from my RCM5700 microcontroller to my email account. I keep getting an error sending the message.
Here is what the SMTP_VERBOSE macro logs:
to:1507
from:14bf
subject:14a8
message:144B
SMTP: Resolving smtp.live.com
SMTP: Opening to 4137ACFE:24b
SMTP: Connected
SMTP: Read: 220 BLU0-SMTP49.phx.gbl Microsoft ESMTP MAIL Service, Version: 6.0.3
790.4675 ready at Sat, 15 Jun 2013 15:00:25 -0SMTP: Wrote EHLO cabin.mn.warpdri
veonline.com
SMTP: Read: 250-BLU0-SMTP49.phx.gbl Hello [24.236.46.37]
SMTP: Read: 250-TURN
SMTP: Read: 250-SIZE 41943040
SMTP: Read: 250-ETRN
SMTP: Read: 250-PIPELINING
SMTP: Read: 250-DSN
SMTP: Read: 250-ENHANCEDSTATUSCODES
SMTP: Read: 250-8bitmime
SMTP: Read: 250-BINARYMIME
SMTP: Read: 250-CHUNKING
SMTP: Read: 250-VRFY
SMTP: Read: 250-TLS
SMTP: Read: 250-STARTTLS
SMTP: Read: 250 OK
Error sending message
I’m communicating successfully with the mail server, but conks out at the end. I know I have to set up a SMTP connection through my email account settings, but when I try, it cannot find the SMTP server. The controller is on my LAN using a static IP address. How do I define the location of my controller’s web server in terms of an email address: Mycontroller@Mydomain.com?
Here is my code (Sorry if hard to read):
/*******************************************************************************
smtp.c
Rabbit Semiconductor, 2000
A small program that uses the SMTP library
to send an e-mail.
*******************************************************************************/
#class auto
/***********************************
- Configuration *
- ------------- *
- All fields in this section must *
- be altered to match your local *
- network settings. *
***********************************/
/*
- NETWORK CONFIGURATION
- Please see the function help (Ctrl-H) on TCPCONFIG for instructions on
- compile-time network configuration.
*/
#define TCPCONFIG 1
#define _PRIMARY_STATIC_IP “192.168.0.100”
#define _PRIMARY_NETMASK “255.255.255.0”
#define MY_GATEWAY “192.168.0.1”
#define MY_NAMESERVER “192.168.0.1”
#define MY_HOST “cabin”
#define MY_DOMAIN “domain.com”
/*
- These macros need to be changed to the appropriate values or
- the smtp_sendmail(…) call in main() needs to be changed to
- reference your values.
*/
#define SMTP_PORT 587
#define FROM “cabin@domain.com”
#define TO “My_Outlook_Email_Address@live.com”
#define SUBJECT “You’ve got mail!”
#define BODY "Visit the Rabbit Semiconductor web site.
"
“There you’ll find the latest news about Dynamic C.”
/*
- The SMTP_SERVER macro tells DCRTCP where your mail server is. This
- mail server MUST be configured to relay mail for your controller.
- This value can be the name or the IP address.
*/
#define SMTP_SERVER “smtp.live.com”
/*
- The SMTP_DOMAIN should be the name of your controller. i.e.
- “somecontroller.somewhere.com” Many SMTP servers ignore this
- value, but some SMTP servers use this field. If you have
- problems, turn on the SMTP_DEBUG macro and see were it is
- bombing out. If it is in the HELO command consult the
- person in charge of the mail server for the appropriate value
- for SMTP_DOMAIN. If you do not define this macro it defaults
- to the value in MY_IP_ADDRESS.
*/
#define SMTP_DOMAIN “cabin.domain.com”
/*
- The SMTP_VERBOSE macro logs the communications between the mail
- server and your controller. Uncomment this define to begin
- logging
*/
#define SMTP_VERBOSE
/*
- The USE_SMTP_AUTH macro enables SMTP Authentication, a method
- where the client authenticates with the server before sending
- a message. Call smtp_setauth() before smtp_sendmail() to set
- the username and password to use for authentication.
*/
#define USE_SMTP_AUTH
/*
- If the following macro is defined, then if SMTP authentication
- fails, the library will NOT attempt non-authenticated SMTP.
*/
#define SMTP_AUTH_FAIL_IF_NO_AUTH
/********************************
- End of configuration section *
********************************/
#memmap xmem
#use dcrtcp.lib
#use smtp.lib
void main()
{
// Start network and wait for interface to come up (or error exit).
sock_init();
while (ifpending(IF_DEFAULT) == IF_COMING_UP) {
tcp_tick(NULL);
}
sethostname(MY_HOST);
setdomainname(MY_DOMAIN);
#ifdef USE_SMTP_AUTH
smtp_setauth (“My_Outlook_SMTP_Username”, “My_Outlook_SMTP_Password”);
#endif
smtp_sendmail(TO, FROM, SUBJECT, BODY);
while(smtp_mailtick()==SMTP_PENDING)
continue;
if(smtp_status()==SMTP_SUCCESS)
printf("Message sent
");
else
printf("Error sending message
");
}