masqmail

view src/smtp_out.h @ 407:164468dd0953

Minor refactoring.
author markus schnalke <meillo@marmaro.de>
date Wed, 29 Feb 2012 10:37:21 +0100
parents b0708fac99dd
children
line source
1 /*
2 ** smtp_out.h
3 ** Copyright (C) Oliver Kurth,
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., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
20 #include <unistd.h>
21 #include <sys/types.h>
22 #include <sys/socket.h>
23 #include <sys/time.h>
24 #include <netinet/in.h>
25 #include <netdb.h>
27 #define SMTP_BUF_LEN 1024
28 #define SMTP_SIZE_ADD 1024 /* add to the size of a message */
30 #define SMTP_INITIAL_TIMEOUT 5*60
31 #define SMTP_CMD_TIMEOUT 5*60
32 #define SMTP_DATA_TIMEOUT 5*60
33 #define SMTP_FINAL_TIMEOUT 10*60
35 typedef enum _smtp_error {
36 smtp_ok = 0, /* mail was delivered to at least one recpient */
37 smtp_trylater, /* server responded with 4xx */
38 smtp_fail, /* server responded with 5xx */
39 smtp_timeout, /* connection timed out */
40 smtp_eof, /* got unexpected EOF */
41 smtp_syntax, /* unexpected response */
42 smtp_cancel /* we gave up (eg. size) */
43 } smtp_error;
46 typedef struct _smtp_base {
47 FILE *in;
48 FILE *out;
50 gint sock;
51 gint dup_sock;
53 gchar *remote_host;
54 gchar *helo_name;
56 gchar *buffer;
57 gint last_code;
59 gboolean use_size;
60 gboolean use_pipelining;
61 gboolean use_auth;
63 gint max_size;
65 gchar **auth_names;
67 gchar *auth_name;
68 gchar *auth_login;
69 gchar *auth_secret;
71 smtp_error error;
73 } smtp_base;
75 gchar *set_heloname(smtp_base *psb, gchar *default_name, gboolean do_correct);
76 gboolean set_auth(smtp_base *psb, gchar *name, gchar *login, gchar *secret);
77 void destroy_smtpbase(smtp_base *psb);
78 smtp_base *smtp_out_open(gchar *host, gint port, GList *resolve_list);
79 smtp_base *smtp_out_open_child(gchar *cmd);
80 gboolean smtp_out_rset(smtp_base *psb);
81 gboolean smtp_out_init(smtp_base *psb, gboolean instant_helo);
82 gint smtp_out_msg(smtp_base *psb, message *msg, address *return_path, GList *rcpt_list, GList *hdr_list);
83 gboolean smtp_out_quit(smtp_base *psb);
84 void smtp_out_mark_rcpts(smtp_base *psb, GList *rcpt_list);
86 gint smtp_deliver(gchar *host, gint port, GList *resolve_list, message *msg, address *return_path, GList *rcpt_list);