| Line No. | Rev | Author | Line |
|---|---|---|---|
| 1 | 32 | kaklik | /********************************************************************* |
| 2 | * |
||
| 3 | * Simple Mail Transfer Protocol (SMTP) Client |
||
| 4 | * Module for Microchip TCP/IP Stack |
||
| 5 | * |
||
| 6 | ********************************************************************* |
||
| 7 | * FileName: SMTP.c |
||
| 8 | * Dependencies: TCP.h |
||
| 9 | * Processor: PIC18, PIC24F, PIC24H, dsPIC30F, dsPIC33F, PIC32 |
||
| 10 | * Compiler: Microchip C32 v1.05 or higher |
||
| 11 | * Microchip C30 v3.12 or higher |
||
| 12 | * Microchip C18 v3.30 or higher |
||
| 13 | * HI-TECH PICC-18 PRO 9.63PL2 or higher |
||
| 14 | * Company: Microchip Technology, Inc. |
||
| 15 | * |
||
| 16 | * Software License Agreement |
||
| 17 | * |
||
| 18 | * Copyright (C) 2002-2009 Microchip Technology Inc. All rights |
||
| 19 | * reserved. |
||
| 20 | * |
||
| 21 | * Microchip licenses to you the right to use, modify, copy, and |
||
| 22 | * distribute: |
||
| 23 | * (i) the Software when embedded on a Microchip microcontroller or |
||
| 24 | * digital signal controller product ("Device") which is |
||
| 25 | * integrated into Licensee's product; or |
||
| 26 | * (ii) ONLY the Software driver source files ENC28J60.c, ENC28J60.h, |
||
| 27 | * ENCX24J600.c and ENCX24J600.h ported to a non-Microchip device |
||
| 28 | * used in conjunction with a Microchip ethernet controller for |
||
| 29 | * the sole purpose of interfacing with the ethernet controller. |
||
| 30 | * |
||
| 31 | * You should refer to the license agreement accompanying this |
||
| 32 | * Software for additional information regarding your rights and |
||
| 33 | * obligations. |
||
| 34 | * |
||
| 35 | * THE SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT |
||
| 36 | * WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT |
||
| 37 | * LIMITATION, ANY WARRANTY OF MERCHANTABILITY, FITNESS FOR A |
||
| 38 | * PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL |
||
| 39 | * MICROCHIP BE LIABLE FOR ANY INCIDENTAL, SPECIAL, INDIRECT OR |
||
| 40 | * CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF |
||
| 41 | * PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS |
||
| 42 | * BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE |
||
| 43 | * THEREOF), ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION, OR OTHER |
||
| 44 | * SIMILAR COSTS, WHETHER ASSERTED ON THE BASIS OF CONTRACT, TORT |
||
| 45 | * (INCLUDING NEGLIGENCE), BREACH OF WARRANTY, OR OTHERWISE. |
||
| 46 | * |
||
| 47 | * |
||
| 48 | * Author Date Comment |
||
| 49 | *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||
| 50 | * Howard Schlunder 3/03/06 Original |
||
| 51 | ********************************************************************/ |
||
| 52 | #ifndef __SMTP_H |
||
| 53 | #define __SMTP_H |
||
| 54 | |||
| 55 | /**************************************************************************** |
||
| 56 | Section: |
||
| 57 | Data Type Definitions |
||
| 58 | ***************************************************************************/ |
||
| 59 | #define SMTP_SUCCESS (0x0000u) // Message was successfully sent |
||
| 60 | #define SMTP_RESOLVE_ERROR (0x8000u) // DNS lookup for SMTP server failed |
||
| 61 | #define SMTP_CONNECT_ERROR (0x8001u) // Connection to SMTP server failed |
||
| 62 | |||
| 63 | /**************************************************************************** |
||
| 64 | Function: |
||
| 65 | typedef struct SMTP_POINTERS |
||
| 66 | |||
| 67 | Summary: |
||
| 68 | Configures the SMTP client to send a message |
||
| 69 | |||
| 70 | Description: |
||
| 71 | This structure of pointers configures the SMTP Client to send an e-mail |
||
| 72 | message. Initially, all pointers will be null. Set <c>SMTPClient.[field |
||
| 73 | name].szRAM</c> to use a string stored in RAM, or <c>SMTPClient.[field |
||
| 74 | name].szROM</c> to use a string stored in ROM. (Where <c>[field name]</c> |
||
| 75 | is one of the parameters below.) |
||
| 76 | |||
| 77 | If a ROM string is specified, <c>SMTPClient.ROMPointers.[field name]</c> |
||
| 78 | must also be set to 1 to indicate that this field should be retrieved |
||
| 79 | from ROM instead of RAM. |
||
| 80 | |||
| 81 | Parameters: |
||
| 82 | Server - the SMTP server to relay the message through |
||
| 83 | Username - the user name to use when logging into the SMTP server, |
||
| 84 | if any is required |
||
| 85 | Password - the password to supply when logging in, if any is required |
||
| 86 | To - the destination address for this message. May be a |
||
| 87 | comma\-separated list of addresss, and/or formatted. |
||
| 88 | CC - The CC addresses for this message, if any. May be a |
||
| 89 | comma\-separated list of addresss, and/or formatted. |
||
| 90 | BCC - The BCC addresses for this message, if any. May be a |
||
| 91 | comma\-separated list of addresss, and/or formatted. |
||
| 92 | From - The From address for this message. May be formatted. |
||
| 93 | Subject - The Subject header for this message. |
||
| 94 | OtherHeaders - Any additional headers for this message. Each additional |
||
| 95 | header, including the last one, must be terminated with |
||
| 96 | a CRLF pair. |
||
| 97 | Body - When sending a message from memory, the location of the |
||
| 98 | body of this message in memory. Leave as NULL to build |
||
| 99 | a message on\-the\-fly. |
||
| 100 | ROMPointers - Indicates which parameters to read from ROM instead of RAM. |
||
| 101 | UseSSL - When STACK_USE_SSL_CLIENT is enabled, this flag causes |
||
| 102 | the SMTP client to make an SSL connection to the server. |
||
| 103 | ServerPort - (WORD value) Indicates the port on which to connect to the |
||
| 104 | remote SMTP server. |
||
| 105 | |||
| 106 | Remarks: |
||
| 107 | When formatting an e-mail address, the SMTP standard format for associating a |
||
| 108 | printable name may be used. This format places the printable name in quotation |
||
| 109 | marks, with the address following in pointed brackets, such as "John Smith" |
||
| 110 | \<john.smith@domain.com\> |
||
| 111 | ***************************************************************************/ |
||
| 112 | typedef struct |
||
| 113 | { |
||
| 114 | union |
||
| 115 | { |
||
| 116 | BYTE *szRAM; |
||
| 117 | ROM BYTE *szROM; |
||
| 118 | } Server; |
||
| 119 | union |
||
| 120 | { |
||
| 121 | BYTE *szRAM; |
||
| 122 | ROM BYTE *szROM; |
||
| 123 | } Username; |
||
| 124 | union |
||
| 125 | { |
||
| 126 | BYTE *szRAM; |
||
| 127 | ROM BYTE *szROM; |
||
| 128 | } Password; |
||
| 129 | union |
||
| 130 | { |
||
| 131 | BYTE *szRAM; |
||
| 132 | ROM BYTE *szROM; |
||
| 133 | } To; |
||
| 134 | union |
||
| 135 | { |
||
| 136 | BYTE *szRAM; |
||
| 137 | ROM BYTE *szROM; |
||
| 138 | } CC; |
||
| 139 | union |
||
| 140 | { |
||
| 141 | BYTE *szRAM; |
||
| 142 | ROM BYTE *szROM; |
||
| 143 | } BCC; |
||
| 144 | union |
||
| 145 | { |
||
| 146 | BYTE *szRAM; |
||
| 147 | ROM BYTE *szROM; |
||
| 148 | } From; |
||
| 149 | union |
||
| 150 | { |
||
| 151 | BYTE *szRAM; |
||
| 152 | ROM BYTE *szROM; |
||
| 153 | } Subject; |
||
| 154 | union |
||
| 155 | { |
||
| 156 | BYTE *szRAM; |
||
| 157 | ROM BYTE *szROM; |
||
| 158 | } OtherHeaders; |
||
| 159 | union |
||
| 160 | { |
||
| 161 | BYTE *szRAM; |
||
| 162 | ROM BYTE *szROM; |
||
| 163 | } Body; |
||
| 164 | |||
| 165 | struct |
||
| 166 | { |
||
| 167 | unsigned char Server:1; |
||
| 168 | unsigned char Username:1; |
||
| 169 | unsigned char Password:1; |
||
| 170 | unsigned char To:1; |
||
| 171 | unsigned char CC:1; |
||
| 172 | unsigned char BCC:1; |
||
| 173 | unsigned char From:1; |
||
| 174 | unsigned char Subject:1; |
||
| 175 | unsigned char OtherHeaders:1; |
||
| 176 | unsigned char Body:1; |
||
| 177 | } ROMPointers; |
||
| 178 | |||
| 179 | #if defined(STACK_USE_SSL_CLIENT) |
||
| 180 | BOOL UseSSL; |
||
| 181 | #endif |
||
| 182 | |||
| 183 | WORD ServerPort; |
||
| 184 | |||
| 185 | } SMTP_POINTERS; |
||
| 186 | |||
| 187 | /**************************************************************************** |
||
| 188 | Section: |
||
| 189 | Global SMTP Variables |
||
| 190 | ***************************************************************************/ |
||
| 191 | extern SMTP_POINTERS SMTPClient; |
||
| 192 | |||
| 193 | /**************************************************************************** |
||
| 194 | Section: |
||
| 195 | SMTP Function Prototypes |
||
| 196 | ***************************************************************************/ |
||
| 197 | |||
| 198 | BOOL SMTPBeginUsage(void); |
||
| 199 | WORD SMTPEndUsage(void); |
||
| 200 | void SMTPTask(void); |
||
| 201 | void SMTPSendMail(void); |
||
| 202 | BOOL SMTPIsBusy(void); |
||
| 203 | WORD SMTPIsPutReady(void); |
||
| 204 | BOOL SMTPPut(BYTE c); |
||
| 205 | WORD SMTPPutArray(BYTE* Data, WORD Len); |
||
| 206 | WORD SMTPPutString(BYTE* Data); |
||
| 207 | void SMTPFlush(void); |
||
| 208 | void SMTPPutDone(void); |
||
| 209 | |||
| 210 | #if defined(__18CXX) |
||
| 211 | WORD SMTPPutROMArray(ROM BYTE* Data, WORD Len); |
||
| 212 | WORD SMTPPutROMString(ROM BYTE* Data); |
||
| 213 | #else |
||
| 214 | // Non-ROM variant for C30 / C32 |
||
| 215 | #define SMTPPutROMArray(a,b) SMTPPutArray((BYTE*)a,b) |
||
| 216 | // Non-ROM variant for C30 / C32 |
||
| 217 | #define SMTPPutROMString(a) SMTPPutString((BYTE*)a) |
||
| 218 | #endif |
||
| 219 | |||
| 220 | |||
| 221 | #endif |
Powered by WebSVN v2.8.3