| The Datasheet Archive - 100 Million Datasheets from 7500 Manufacturers. |
MCUs Application Note Rev. 4120A-8051-04/02 E-mail Delivery:
Top Searches for this datasheetThis application note explains microcontrollers send e-mail using common protocol Internet SMTP. Currently, most Atmel microcontrollers capable sending e-mail worldwide. This application note describes efficient implementation Simple Mail Transfer Protocol (SMTP) with @Web TCP/IP library. This application note describes interface SMTP client firmware through simple e-mail API. full source code SMTP client e-mail given SMTP.html file available dowloaded (Zip) package. MCUs Application Note Rev. 4120A-8051-04/02 E-mail Delivery: SMTP Internet TCP/IP Based Protocols TCP/IP provides reliable data transfer through networks (such Internet). TCP/IP universal method establish full duplex communication channel between hosts network. Simple Mail Transfer Protocol, like most TCP/IP based protocols, defines simple ASCII commands replies between server (that will receive transfer e-mail) client (that intends communicate e-mail server). sender, posting e-mail worldwide means communicating with only SMTP server. e-mail delivery ensured SMTP server. Figure Overview Internet Environment SMTP server SMTP client TCP/IP modem 8-bit microcontroller TCP/IP TCP/IP Internet TCP/IP Internet host Internet host Internet host SMTP protocol described 2821 (see http://www.rfc-editor.org), which replaces (obsolete). message format e-mail, after DATA command) specified 2822, this document explains send attachments complex messages. previous figure example configuration overview: three Internet hosts, SMTP server 8-bit microcontroller communicate e-mail through TCP/IP network (Internet). Each peer physically distant from each other, several thousands kilometers. @Web SMTP 4120A-8051-04/02 @Web SMTP More About SMTP SMTP uses Internet standard reply codes: first three ASCII digits have special significance. instance `xyz' reply code, first digit gives following information: means Positive Preliminary reply Positive Completion reply Positive Intermediate reply Transient Negative Completion reply Permanent Negative Completion reply Syntax Information Connections etc, 2821 more information second digit encodes responses specific categories: following scenario, reply from Server, command from Client. text bold format sent microcontroller, normal text received italic text just highlight transaction direction. Typical SMTP client/server transaction scenario: <The client establishes connection SMTP server port> mail.atmel-nantes.fr Simple Mail Transfer Service Ready HELO c51uweb mail.atmel-nantes.fr MAIL FROM:<c51uweb@atmel-nantes.fr> RCPT TO:<tom.jones@atmel-nantes.fr> DATA Start mail input; with Date: Thu, 2001 05:33:22 -0700 From: C51µWeb Subject: Next Meeting Board Jones Tom: next meeting board directors will Tuesday. C51µWeb. QUIT mail.atmel-nantes.fr Service closing transmission channel <The client server close connection> 4120A-8051-04/02 E-mail Client Sending this type e-mail will probably take seconds SMTP client/server transaction about seconds complete delivery worldwide through Internet. Figure Screenshot Email Client seconds after e-mail sent) Tom: Often, e-mail will arrive directly computer recipient address. main reasons this are: this computer on-line this computer does have working SMTP server Usually, SMTP server company) stores e-mail dedicated mailbox clients employees). These people another protocol read mailbox, mainly: Post Office Protocol (nowadays version POP3) Internet Message Access Protocol (nowadays version 4rev1 IMAP4) described following section, there usually SMTP client (the sender), several SMTP clients/servers (the relay hosts) POP3 client (the recipient) email delivery process. @Web SMTP 4120A-8051-04/02 @Web SMTP Network network (Internet, intranet other network) used "data packet transfer" service. following figure, each circle network host computer, router, server, etc.). Data packets circulate this network step step (hop over network links). Figure Network Overview Embedded SMTP client above figure shows that data path over networks unique change between consecutive packets. distance over network increases number hops, speed links quality transmission, rather than number kilometers between client server. Some nodes this network have seen part SMTP transactions. following figure shows first SMTP transactions between microcontroller first SMTP server (here, there "data packets", 3.2K byte e-mail). 4120A-8051-04/02 Figure Network Activity Startup initialization function init_smtp_client. This function must called before other function e-mail initialize client) after error registered resume this error). This function sets some global variables e-mail state machine. This main part e-mail's sending service. This simple client fits unique function called smtp_client. send e-mail, this function must called regularly, about five times second, about five seconds simple e-mail. This function (and entire API) compliant with cooperative multitasking environment. Sending simple e-mail (without image attachments) overloading task, network microcontroller. state variables allow know exactly what SMTP clients smtp_internal_state, state variable main state machine smtp_client smtp_state, used additional information SMTP Client @Web SMTP 4120A-8051-04/02 @Web SMTP Recipient E-mail function send_email_to sets recipient e-mail. This uses only recipient easily upgraded multiple recipients. following part SMTP client/server transaction scenario shows several recipients same e-mail. Each command RCPT adds recipient. Scenario with more recipients: mail.atmel-nantes.fr Simple Mail Transfer Service Ready HELO c51uweb mail.atmel-nantes.fr MAIL FROM:<c51uweb@atmel-nantes.fr> RCPT TO:<tom.jones@atmel-nantes.fr> RCPT RCPT DATA Start mail input; with Content Transfer default, this sends pre-defined e-mail. However, there templates rapidly customize final application: change pre-defined e-mail send send types e-mail, including dynamic information e-mail content must 2822 compliant. Some work usually done send complex e-mail such base64 encoding. This doesn't provide general functions this because software designer drastically simplify content formating particular application. change pre-defined e-mail, variable smtp_test activate your choice. Example: #define I_HAVE_smtp_test_VARIABLE smtp_test[]="Simple test SMTP client with pre-defined e-mail."; change pre-defined function that sends e-mail content default, this funct sends _test content write func tion send_email_content, based TCP/IP API. Example (send empty e-mail): #define send_email_content (void) return TRUE; Tell SMTP client that e-mail content sent This function called smtp_client when e-mail content must sent. Until return value TRUE, this function called often smtp_client called. 4120A-8051-04/02 Minimal Source Code #include "tcpip.h" #include "smtp.h" void main (void) Minimal prog which send pre-defined e-mail name@company.org init_network(); init_smtp_client(); send_email_to ("name@company.org") while smtp_internal_state SMTP_WAIT_APPLI) smtp_client (smtp_state SMTP_ERROR_SERVER) Sending error else Mail sent Implementation Notes TCP/IP SMTP client implementation uses following calls TCP/IP API: tcp_open, initiate full-duplex TCP/IP connection with SMTP server tcp_send, send commands tcp_receive, receive replies tcp_close, close connection parse_internet_code, parse server reply Multi-line Reply Internet Code Parser provided parse_internet_code compliant with re-packetization multi-line replies, according 2821. Here example multiline reply: 123-First line 123-Second line 123-234 text beginning with numbers last line equivalent line: Same information, terminated <CRLF> @Web SMTP 4120A-8051-04/02 @Web SMTP State Machine smtp_client Figure SMTP Client State Machine init_smtp_client() Wait Appli send_email_to("addr") smtp_to:="addr" Open Port Client/Server Ready disconnection tcp_close() init_smtp_client() Wait Ready tcp_receive() small segment multiline reply Update Internet Code Parser Protocol Parser Typical scenario Client/Server Ready mail transfer Send Info tcp_open(SMTP_param) Reset Internet Code Parser tcp_send() Internet Code Parser Error atypical Internet Code reply tcp_close() smtp_state:=SMTP_ERROR_ SERVER Wait Appli send_email_content()() Mail Transfer Note: smtp_state SMTP_WAIT_SERVER init_smtp_client. 4120A-8051-04/02 References Atmel @Web TCP/IP Stack Documentation (included with source code downloadable package) TCP/IP Illustrated, Volume Protocols Richard Stevens TCP/IP Tutorial Technical Overview Rodriguez ibm.com/redbooks 1049: Content-type Header Field Internet Messages 1652: SMTP Service Extension 8bit-MIME Transport 1939: Post Office Protocol Version 2060: Internet Message Access Protocol Version4rev1 2821: Simple Mail Transfer Protocol 2822: Internet Message Format Acronyms API: Application Program Interface ASCII: American Standard Code Information Interchange CRLF: Cariage-Return; Linefeed IETF: Internet Engineering Task Force Internet Protocol MIME: Multipurpose Internet Mail Extensions RFC: Request Comments SMTP: Simple Mail Transfer Protocol TCP: Transfer Control Protocol @Web SMTP 4120A-8051-04/02 Atmel Headquarters Corporate Headquarters 2325 Orchard Parkway Jose, 95131 1(408) 441-0311 1(408) 487-2600 Atmel Operations Memory 2325 Orchard Parkway Jose, 95131 1(408) 441-0311 1(408) 436-4314 RF/Automotive Theresienstrasse Postfach 3535 74025 Heilbronn, Germany (49) 71-31-67-0 (49) 71-31-67-2340 1150 East Cheyenne Mtn. Blvd. Colorado Springs, 80906 1(719) 576-3300 1(719) 540-1759 Europe Atmel Sarl Route Arsenaux Case Postale CH-1705 Fribourg Switzerland (41) 26-426-5555 (41) 26-426-5500 Microcontrollers 2325 Orchard Parkway Jose, 95131 1(408) 441-0311 1(408) 436-4314 Chantrerie 70602 44306 Nantes Cedex France (33) 2-40-18-18-18 (33) 2-40-18-19-60 Asia Room 1219 Chinachem Golden Plaza Mody Road Tsimhatsui East Kowloon Hong Kong (852) 2721-9778 (852) 2722-1369 Biometrics/Imaging/Hi-Rel MPU/ High Speed Converters/RF Datacom Avenue Rochepleine 38521 Saint-Egreve Cedex, France (33) 4-76-58-30-00 (33) 4-76-58-34-80 ASIC/ASSP/Smart Cards Zone Industrielle 13106 Rousset Cedex, France (33) 4-42-53-60-00 (33) 4-42-53-60-01 1150 East Cheyenne Mtn. Blvd. Colorado Springs, 80906 1(719) 576-3300 1(719) 540-1759 Scottish Enterprise Technology Park Maxwell Building East Kilbride 0QR, Scotland (44) 1355-803-000 (44) 1355-242-743 Japan Tonetsu Shinkawa Bldg. 1-24-8 Shinkawa Chuo-ku, Tokyo 104-0033 Japan (81) 3-3523-3551 (81) 3-3523-7581 literature@atmel.com Site http://www.atmel.com Atmel Corporation 2002. Atmel Corporation makes warranty products, other than those expressly contained Company's standard warranty which detailed Atmel's Terms Conditions located Company's site. Company assumes responsibility errors which appear this document, reserves right change devices specifications detailed herein time without notice, does make commitment update information contained herein. licenses patents other intellectual property Atmel granted Company connection with sale Atmel products, expressly implication. Atmel's products authorized critical components life support devices systems. ATMEL registered trademark Atmel. Other terms product names trademarks others. Printed recycled paper. 4120A-8051-04/02 Other recent searchesTSOP44 - TSOP44 TSOP44 Datasheet STTH10LCD06 - STTH10LCD06 STTH10LCD06 Datasheet SIL87374x - SIL87374x SIL87374x Datasheet PT4120 - PT4120 PT4120 Datasheet MPC862EC - MPC862EC MPC862EC Datasheet MPC862 - MPC862 MPC862 Datasheet 857T - 857T 857T Datasheet 857DSL - 857DSL 857DSL Datasheet MPC862P - MPC862P MPC862P Datasheet M950x0 - M950x0 M950x0 Datasheet M950x0-W - M950x0-W M950x0-W Datasheet M950x0-R - M950x0-R M950x0-R Datasheet DM-4105 - DM-4105 DM-4105 Datasheet AAT7200 - AAT7200 AAT7200 Datasheet
Privacy Policy | Disclaimer |