talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

smtp.h (2378B)


      1 /*
      2  * Claws Mail -- a GTK based, lightweight, and fast e-mail client
      3  * Copyright (C) 1999-2012 Hiroyuki Yamamoto and the Claws Mail team
      4  *
      5  * This program is free software; you can redistribute it and/or modify
      6  * it under the terms of the GNU General Public License as published by
      7  * the Free Software Foundation; either version 3 of the License, or
      8  * (at your option) any later version.
      9  *
     10  * This program is distributed in the hope that it will be useful,
     11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13  * GNU General Public License for more details.
     14  *
     15  * You should have received a copy of the GNU General Public License
     16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
     17  *
     18  */
     19 
     20 #ifndef __SMTP_H__
     21 #define __SMTP_H__
     22 
     23 #include <glib.h>
     24 
     25 #include "session.h"
     26 
     27 typedef struct _SMTPSession	SMTPSession;
     28 
     29 #define SMTP_SESSION(obj)	((SMTPSession *)obj)
     30 
     31 #define MESSAGEBUFSIZE		8192
     32 
     33 typedef enum
     34 {
     35 	SM_OK			= 0,
     36 	SM_ERROR		= 128,
     37 	SM_UNRECOVERABLE	= 129,
     38 	SM_AUTHFAIL		= 130
     39 } SMTPErrorValue;
     40 
     41 typedef enum
     42 {
     43 	ESMTP_8BITMIME	= 1 << 0,
     44 	ESMTP_SIZE	= 1 << 1,
     45 	ESMTP_ETRN	= 1 << 2
     46 } ESMTPFlag;
     47 
     48 typedef enum
     49 {
     50 	SMTPAUTH_LOGIN      = 1 << 0,
     51 	SMTPAUTH_CRAM_MD5   = 1 << 1,
     52 	SMTPAUTH_DIGEST_MD5 = 1 << 2,
     53 	SMTPAUTH_TLS_AVAILABLE = 1 << 3,
     54 	SMTPAUTH_PLAIN      = 1 << 4,
     55 	SMTPAUTH_OAUTH2     = 1 << 5
     56 } SMTPAuthType;
     57 
     58 typedef enum
     59 {
     60 	SMTP_READY,
     61 	SMTP_HELO,
     62 	SMTP_EHLO,
     63 	SMTP_STARTTLS,
     64 	SMTP_FROM,
     65 	SMTP_AUTH,
     66 	SMTP_AUTH_LOGIN_USER,
     67 	SMTP_AUTH_LOGIN_PASS,
     68 	SMTP_AUTH_CRAM_MD5,
     69 	SMTP_AUTH_PLAIN,
     70 	SMTP_AUTH_OAUTH2,
     71 	SMTP_RCPT,
     72 	SMTP_DATA,
     73 	SMTP_SEND_DATA,
     74 	SMTP_EOM,
     75 	SMTP_RSET,
     76 	SMTP_QUIT,
     77 	SMTP_ERROR,
     78 	SMTP_DISCONNECTED,
     79 	SMTP_MAIL_SENT_OK,
     80 
     81 	N_SMTP_PHASE
     82 } SMTPState;
     83 
     84 struct _SMTPSession
     85 {
     86 	Session session;
     87 
     88 	SMTPState state;
     89 
     90 	gchar *hostname;
     91 
     92 	gchar *user;
     93 	gchar *pass;
     94 
     95 	gchar *from;
     96 	GSList *to_list;
     97 	GSList *cur_to;
     98 
     99 	guchar *send_data;
    100 	guint send_data_len;
    101 
    102 	guint max_message_size;
    103 
    104 	SMTPAuthType avail_auth_type;
    105 	SMTPAuthType forced_auth_type;
    106 	SMTPAuthType auth_type;
    107 
    108 	SMTPErrorValue error_val;
    109 	gchar *error_msg;
    110 	gboolean is_esmtp;
    111 	ESMTPFlag esmtp_flags;
    112 
    113 	void *dialog;
    114 	gboolean tls_init_done;
    115 };
    116 
    117 Session *smtp_session_new	(void *prefs_account);
    118 gint smtp_from(SMTPSession *session);
    119 gint smtp_quit(SMTPSession *session);
    120 
    121 #endif /* __SMTP_H__ */