Corrected a bug that prevented sylpheed to open
[claws.git] / src / smtp.h
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2002 Hiroyuki Yamamoto
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 2 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, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 #ifndef __SMTP_H__
21 #define __SMTP_H__
22
23 #ifdef HAVE_CONFIG_H
24 #  include "config.h"
25 #endif
26
27 #include <glib.h>
28
29 #include "socket.h"
30 #if USE_SSL
31 #  include "ssl.h"
32 #endif
33 #include "session.h"
34
35 typedef struct _SMTPSession     SMTPSession;
36
37 #define SMTP_SESSION(obj)       ((SMTPSession *)obj)
38
39 #define MSGBUFSIZE              8192
40
41 #define SM_OK                   0
42 #define SM_ERROR                128
43 #define SM_UNRECOVERABLE        129
44 #define SM_AUTHFAIL             130
45
46 #define ESMTP_8BITMIME          0x01
47 #define ESMTP_SIZE              0x02
48 #define ESMTP_ETRN              0x04
49
50 #if USE_SSL
51 typedef enum
52 {
53         SSL_SMTP_NONE,
54         SSL_SMTP_TUNNEL,
55         SSL_SMTP_STARTTLS
56 } SSLSMTPType;
57 #endif
58
59 typedef enum
60 {
61         SMTPAUTH_LOGIN      = 1 << 0,
62         SMTPAUTH_CRAM_MD5   = 1 << 1,
63         SMTPAUTH_DIGEST_MD5 = 1 << 2
64 } SMTPAuthType;
65
66 struct _SMTPSession
67 {
68         Session session;
69
70         SMTPAuthType avail_auth_type;
71         gchar *user;
72         gchar *pass;
73 };
74
75 #if USE_SSL
76 Session *smtp_session_new       (const gchar    *server,
77                                  gushort         port,
78                                  const gchar    *domain,
79                                  const gchar    *user,
80                                  const gchar    *pass,
81                                  SSLSMTPType     ssl_type);
82 #else
83 Session *smtp_session_new       (const gchar    *server,
84                                  gushort         port,
85                                  const gchar    *domain,
86                                  const gchar    *user,
87                                  const gchar    *pass);
88 #endif
89 void smtp_session_destroy       (SMTPSession    *session);
90
91 gint smtp_from                  (SMTPSession    *session,
92                                  const gchar    *from);
93 gint smtp_auth                  (SMTPSession    *session);
94
95 gint smtp_ehlo                  (SockInfo       *sock,
96                                  const gchar    *hostname,
97                                  SMTPAuthType   *avail_auth_type);
98
99 gint smtp_helo                  (SockInfo       *sock,
100                                  const gchar    *hostname);
101 gint smtp_rcpt                  (SockInfo       *sock,
102                                  const gchar    *to);
103 gint smtp_data                  (SockInfo       *sock);
104 gint smtp_rset                  (SockInfo       *sock);
105 gint smtp_quit                  (SockInfo       *sock);
106 gint smtp_eom                   (SockInfo       *sock);
107
108 #endif /* __SMTP_H__ */