Nut/OS  4.10.3
API Reference
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 #include <sys/socket.h>
00052 
00057 
00058 #ifndef MAX_MAIL_RCPTS
00059 
00060 #define MAX_MAIL_RCPTS  4
00061 #endif
00062 
00066 #define MAIL_RCPT_TYPE  0x03
00067 
00068 #define MAIL_RCPT_TO    0x01
00069 
00070 #define MAIL_RCPT_CC    0x02
00071 
00072 #define MAIL_RCPT_BCC   0x03
00073 
00074 #define MAIL_RCPT_ACPT  0x20
00075 
00076 #define MAIL_RCPT_SENT  0x40
00077 
00078 #define MAIL_RCPT_FAIL  0x80
00079 
00080 #define MAIL_RCPT_DONE  (MAIL_RCPT_SENT | MAIL_RCPT_FAIL)
00081 
00086 typedef struct _MAILENVELOPE {
00088     time_t mail_date;
00090     char *mail_from;
00092     char *mail_from_header;
00094     char *mail_subj;
00096     char *mail_body;
00098     char *mail_rcpt[MAX_MAIL_RCPTS];
00100     char *mail_rcpt_header[MAX_MAIL_RCPTS];
00102     uint8_t mail_rcpt_stat[MAX_MAIL_RCPTS];
00103 } MAILENVELOPE;
00104 
00105 #ifndef SMTP_BUFSIZ
00106 
00107 #define SMTP_BUFSIZ     256
00108 #endif
00109 
00113 #define SMTPFEAT_VINTAGE        0x00000001
00114 
00115 #define SMTPFEAT_AUTH_LOGIN     0x00000002
00116 
00117 #define SMTPFEAT_AUTH_PLAIN     0x00000004
00118 
00123 typedef struct _SMTPCLIENTSESSION {
00125     TCPSOCKET *smtp_sock;
00127     FILE *smtp_stream;
00129     uint32_t smtp_feat;
00131     char smtp_buff[SMTP_BUFSIZ];
00132 } SMTPCLIENTSESSION;
00133 
00136 __BEGIN_DECLS
00137 /* Prototypes */
00138 
00139 extern SMTPCLIENTSESSION * NutSmtpConnect(uint32_t ip, uint16_t port);
00140 extern void NutSmtpDisconnect(SMTPCLIENTSESSION *si);
00141 extern int NutSmtpLogin(SMTPCLIENTSESSION *si, char *host, char *user, char *pass);
00142 
00143 extern CONST char *NutSmtpSendMail(SMTPCLIENTSESSION *si, MAILENVELOPE *me);
00144 extern int NutSmtpSendMailRequest(SMTPCLIENTSESSION *si, MAILENVELOPE *me);
00145 extern int NutSmtpSendMailHeader(SMTPCLIENTSESSION *si, MAILENVELOPE *me);
00146 extern int NutSmtpSendEncodedLines(SMTPCLIENTSESSION *si, CONST char *text);
00147 
00148 extern CONST char *NutSmtpSendCommand(SMTPCLIENTSESSION *si, CONST char *fmt, ...);
00149 extern CONST char *NutSmtpReceiveResponse(SMTPCLIENTSESSION *si);
00150 
00151 __END_DECLS
00152 /* End of prototypes */
00153 #endif