masqmail

view src/smtp_out.h @ 323:29de6a1c4538

Fixed an important bug with folded headers! g_strconcat() returns a *copy* of the string, but hdr->value still pointed to the old header (which probably was a memory leak, too). If the folded part had been quite small it was likely that the new string was at the same position as the old one, thus making everything go well. But if pretty long headers were folded several times it was likely that the new string was allocated somewhere else in memory, thus breaking things. In result mails to lots of recipients (folded header) were frequently only sent to the ones in the first line. Sorry for the inconvenience.
author meillo@marmaro.de
date Fri, 03 Jun 2011 09:47:27 +0200
parents 4cff8638dd9b
children 41958685480d
line source
1 /* smtp_out.h, Copyright (C) Oliver Kurth,
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 */
18 #include <unistd.h>
19 #include <sys/types.h>
20 #include <sys/socket.h>
21 #include <sys/time.h>
22 #include <netinet/in.h>
23 #include <netdb.h>
25 #define SMTP_BUF_LEN 1024
26 #define SMTP_SIZE_ADD 1024 /* add to the size of a message */
28 #define SMTP_INITIAL_TIMEOUT 5*60
29 #define SMTP_CMD_TIMEOUT 5*60
30 #define SMTP_DATA_TIMEOUT 5*60
31 #define SMTP_FINAL_TIMEOUT 10*60
33 typedef enum _smtp_error {
34 smtp_ok = 0, /* mail was delivered to at least one recpient */
35 smtp_trylater, /* server responded with 4xx */
36 smtp_fail, /* server responded with 5xx */
37 smtp_timeout, /* connection timed out */
38 smtp_eof, /* got unexpected EOF */
39 smtp_syntax, /* unexpected response */
40 smtp_cancel /* we gave up (eg. size) */
41 } smtp_error;
44 typedef struct _smtp_base {
45 FILE *in;
46 FILE *out;
48 gint sock;
49 gint dup_sock;
51 gchar *remote_host;
52 gchar *helo_name;
54 gchar *buffer;
55 gint last_code;
57 gboolean use_size;
58 gboolean use_pipelining;
59 gboolean use_auth;
61 gint max_size;
63 gchar **auth_names;
65 gchar *auth_name;
66 gchar *auth_login;
67 gchar *auth_secret;
69 smtp_error error;
71 } smtp_base;
73 gchar *set_heloname(smtp_base * psb, gchar * default_name, gboolean do_correct);
74 gboolean set_auth(smtp_base * psb, gchar * name, gchar * login, gchar * secret);
75 void destroy_smtpbase(smtp_base * psb);
76 smtp_base *smtp_out_open(gchar * host, gint port, GList * resolve_list);
77 smtp_base *smtp_out_open_child(gchar * cmd, char* host);
78 gboolean smtp_out_rset(smtp_base * psb);
79 gboolean smtp_out_init(smtp_base * psb, gboolean instant_helo);
80 gint smtp_out_msg(smtp_base * psb, message * msg, address * return_path, GList * rcpt_list, GList * hdr_list);
81 gboolean smtp_out_quit(smtp_base * psb);
83 gint smtp_deliver(gchar * host, gint port, GList * resolve_list, message * msg, address * return_path, GList * rcpt_list);