smtpc.h

Go to the documentation of this file.
00001 #ifndef PRO_SMTPC_H
00002 #define PRO_SMTPC_H
00003 
00004 /*
00005  * Copyright 2010 by egnite GmbH
00006  *
00007  * All rights reserved.
00008  *
00009  * Redistribution and use in source and binary forms, with or without
00010  * modification, are permitted provided that the following conditions
00011  * are met:
00012  *
00013  * 1. Redistributions of source code must retain the above copyright
00014  *    notice, this list of conditions and the following disclaimer.
00015  * 2. Redistributions in binary form must reproduce the above copyright
00016  *    notice, this list of conditions and the following disclaimer in the
00017  *    documentation and/or other materials provided with the distribution.
00018  * 3. Neither the name of the copyright holders nor the names of
00019  *    contributors may be used to endorse or promote products derived
00020  *    from this software without specific prior written permission.
00021  *
00022  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00025  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00026  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00027  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00028  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00029  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00030  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00031  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
00032  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00033  * SUCH DAMAGE.
00034  *
00035  * For additional information see http://www.ethernut.de/
00036  */
00037 
00047 #include <stdio.h>
00048 #include <time.h>
00049 
00050 #include <cfg/smtp.h>
00051 
00056 
00057 #ifndef MAX_MAIL_RCPTS
00058 
00059 #define MAX_MAIL_RCPTS  4
00060 #endif
00061 
00065 #define MAIL_RCPT_TYPE  0x03
00066 
00067 #define MAIL_RCPT_TO    0x01
00068 
00069 #define MAIL_RCPT_CC    0x02
00070 
00071 #define MAIL_RCPT_BCC   0x03
00072 
00073 #define MAIL_RCPT_ACPT  0x20
00074 
00075 #define MAIL_RCPT_SENT  0x40
00076 
00077 #define MAIL_RCPT_FAIL  0x80
00078 
00079 #define MAIL_RCPT_DONE  (MAIL_RCPT_SENT | MAIL_RCPT_FAIL)
00080 
00085 typedef struct _MAILENVELOPE {
00087     time_t mail_date;
00089     char *mail_from;
00091     char *mail_subj;
00093     char *mail_body;
00095     char *mail_rcpt[MAX_MAIL_RCPTS];
00097     uint8_t mail_rcpt_stat[MAX_MAIL_RCPTS];
00098 } MAILENVELOPE;
00099 
00100 #ifndef SMTP_BUFSIZ
00101 
00102 #define SMTP_BUFSIZ     256
00103 #endif
00104 
00108 #define SMTPFEAT_VINTAGE        0x00000001
00109 
00110 #define SMTPFEAT_AUTH_LOGIN     0x00000002
00111 
00112 #define SMTPFEAT_AUTH_PLAIN     0x00000004
00113 
00118 typedef struct _SMTPCLIENTSESSION {
00120     TCPSOCKET *smtp_sock;
00122     FILE *smtp_stream;
00124     uint32_t smtp_feat;
00126     char smtp_buff[SMTP_BUFSIZ];
00127 } SMTPCLIENTSESSION;
00128 
00131 __BEGIN_DECLS
00132 /* Prototypes */
00133 
00134 extern SMTPCLIENTSESSION * NutSmtpConnect(uint32_t ip, uint16_t port);
00135 extern void NutSmtpDisconnect(SMTPCLIENTSESSION *si);
00136 extern int NutSmtpLogin(SMTPCLIENTSESSION *si, char *host, char *user, char *pass);
00137 
00138 extern CONST char *NutSmtpSendMail(SMTPCLIENTSESSION *si, MAILENVELOPE *me);
00139 extern int NutSmtpSendMailRequest(SMTPCLIENTSESSION *si, MAILENVELOPE *me);
00140 extern int NutSmtpSendMailHeader(SMTPCLIENTSESSION *si, MAILENVELOPE *me);
00141 extern int NutSmtpSendEncodedLines(SMTPCLIENTSESSION *si, CONST char *text);
00142 
00143 extern CONST char *NutSmtpSendCommand(SMTPCLIENTSESSION *si, CONST char *fmt, ...);
00144 extern CONST char *NutSmtpReceiveResponse(SMTPCLIENTSESSION *si);
00145 
00146 __END_DECLS
00147 /* End of prototypes */
00148 #endif

© 2000-2010 by contributors - visit http://www.ethernut.de/