Hi.

Not sure if this helps, but some time ago I wanted to send email status reports from an embedded device.
I did it like this:

3 parts of the email message

1) To connect to the smtp server
char email[] = "HELO some.smtp.server\r\nMAIL FROM: [EMAIL PROTECTED] TO: [EMAIL 
PROTECTED] message is:\r\n";
Replace [EMAIL PROTECTED] with actual email addresses.

2) strcat the actual data, gathered and formatted somewhere else with 1)

3) End communicating with smtp server and strcat with the rest
char part3[] = "\r\n.\r\nquit\r\n";

The actual function taking care of establishing the tcp connection etc. is something like this:

char string[255];

void sendmessage()
{
  struct tcp_pcb *pcb;
  struct ip_addr ipaddr;

  u16_t port = 25; //smtp
  err_t err;

strcat(string,email);
strcat(string,data);
strcat(string,part3);


  IP4_ADDR(&ipaddr, xxx,xxx,xxx,xxx); //IP address of smtp server
  pcb = tcp_new();

tcp_bind(pcb, IP_ADDR_ANY, 100);

err = tcp_connect(pcb, &ipaddr, port, write_email);
}


Where the function write_email is this:

static err_t write_email(void *arg, struct tcp_pcb *tpcb, err_t err)
{
err_t new_err;

  new_err=tcp_write(tpcb,(void *)string,sizeof(string),0);

  return new_err;
}


This was just a simple hack I put together to report the current IP address of the embedded device (M32C Microcontroller) which it got from a DHCP server.


Best regards,
Johan




On Wed, 4 Jan 2006, Wang Zheng wrote:

hi all,

 I want to port a snmp protocol to the lwip.

 Is there anybody has some interrelated experience. And would you like to give 
me some advice or give me some samples. Where should I begin with ?

 thanks!

__________________________________________________
¸Ï¿ì×¢²áÑÅ»¢³¬´óÈÝÁ¿Ãâ·ÑÓÊÏä?
http://cn.mail.yahoo.com
_______________________________________________
lwip-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to