masqmail

annotate src/smtp_out.h @ 117:5ec5e6637049

added server-side SMTP SIZE support (patch by Paolo) ``SIZE 0'' (= unlimited) is currently not supported client-side support was already implemented
author meillo@marmaro.de
date Thu, 01 Jul 2010 13:08:53 +0200
parents 08114f7dcc23
children 1e2fd87d58ea
rev   line source
meillo@0 1 /* smtp_out.h, Copyright (C) Oliver Kurth,
meillo@0 2 *
meillo@0 3 * This program is free software; you can redistribute it and/or modify
meillo@0 4 * it under the terms of the GNU General Public License as published by
meillo@0 5 * the Free Software Foundation; either version 2 of the License, or
meillo@0 6 * (at your option) any later version.
meillo@10 7 *
meillo@0 8 * This program is distributed in the hope that it will be useful,
meillo@0 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
meillo@0 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
meillo@0 11 * GNU General Public License for more details.
meillo@0 12 *
meillo@0 13 * You should have received a copy of the GNU General Public License
meillo@0 14 * along with this program; if not, write to the Free Software
meillo@0 15 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
meillo@0 16 */
meillo@0 17
meillo@0 18 #include <unistd.h>
meillo@0 19 #include <sys/types.h>
meillo@0 20 #include <sys/socket.h>
meillo@0 21 #include <sys/time.h>
meillo@0 22 #include <netinet/in.h>
meillo@0 23 #include <netdb.h>
meillo@0 24
meillo@0 25 #define SMTP_BUF_LEN 1024
meillo@0 26 #define SMTP_SIZE_ADD 1024
meillo@0 27
meillo@0 28 #define SMTP_INITIAL_TIMEOUT 5*60
meillo@0 29 #define SMTP_CMD_TIMEOUT 5*60
meillo@0 30 #define SMTP_DATA_TIMEOUT 5*60
meillo@0 31 #define SMTP_FINAL_TIMEOUT 10*60
meillo@0 32
meillo@10 33 typedef enum _smtp_error {
meillo@10 34 smtp_ok = 0, /* mail was delivered to at least one recpient */
meillo@10 35 smtp_trylater, /* server responded with 4xx */
meillo@10 36 smtp_fail, /* server responded with 5xx */
meillo@10 37 smtp_timeout, /* connection timed out */
meillo@10 38 smtp_eof, /* got unexpected EOF */
meillo@10 39 smtp_syntax, /* unexpected response */
meillo@10 40 smtp_cancel /* we gave up (eg. size) */
meillo@0 41 } smtp_error;
meillo@0 42
meillo@0 43
meillo@10 44 typedef struct _smtp_base {
meillo@10 45 FILE *in;
meillo@10 46 FILE *out;
meillo@0 47
meillo@10 48 gint sock;
meillo@10 49 gint dup_sock;
meillo@0 50
meillo@10 51 gchar *remote_host;
meillo@10 52 gchar *helo_name;
meillo@0 53
meillo@10 54 gchar *buffer;
meillo@10 55 gint last_code;
meillo@0 56
meillo@10 57 gboolean use_esmtp;
meillo@10 58 gboolean use_size;
meillo@10 59 gboolean use_pipelining;
meillo@10 60 gboolean use_auth;
meillo@0 61
meillo@10 62 gint max_size;
meillo@0 63
meillo@10 64 gchar **auth_names;
meillo@0 65
meillo@10 66 gchar *auth_name;
meillo@10 67 gchar *auth_login;
meillo@10 68 gchar *auth_secret;
meillo@10 69
meillo@10 70 smtp_error error;
meillo@0 71
meillo@0 72 } smtp_base;
meillo@0 73
meillo@10 74 gchar *set_heloname(smtp_base * psb, gchar * default_name, gboolean do_correct);
meillo@10 75 gboolean set_auth(smtp_base * psb, gchar * name, gchar * login, gchar * secret);
meillo@10 76 void destroy_smtpbase(smtp_base * psb);
meillo@10 77 smtp_base *smtp_out_open(gchar * host, gint port, GList * resolve_list);
meillo@10 78 smtp_base *smtp_out_open_child(gchar * cmd);
meillo@10 79 gboolean smtp_out_rset(smtp_base * psb);
meillo@10 80 gboolean smtp_out_init(smtp_base * psb);
meillo@10 81 gint smtp_out_msg(smtp_base * psb, message * msg, address * return_path, GList * rcpt_list, GList * hdr_list);
meillo@10 82 gboolean smtp_out_quit(smtp_base * psb);
meillo@0 83
meillo@10 84 gint smtp_deliver(gchar * host, gint port, GList * resolve_list, message * msg, address * return_path, GList * rcpt_list);