189ad9caa5e8f5cedba7a62ab8d1b3aa5faa5b4c
[users/heiko/exim.git] / src / src / transports / smtp.h
1 /*************************************************
2 *     Exim - an Internet mail transport agent    *
3 *************************************************/
4
5 /* Copyright (c) University of Cambridge 1995 - 2018 */
6 /* Copyright (c) The Exim Maintainers 2020 */
7 /* See the file NOTICE for conditions of use and distribution. */
8
9 #define DELIVER_BUFFER_SIZE 4096
10
11 #define PENDING          256
12 #define PENDING_DEFER   (PENDING + DEFER)
13 #define PENDING_OK      (PENDING + OK)
14
15
16 /* Private structure for the private options and other private data. */
17
18 typedef struct {
19   uschar        *hosts;
20   uschar        *fallback_hosts;
21   host_item     *hostlist;
22   host_item     *fallback_hostlist;
23   uschar        *authenticated_sender;
24   uschar        *helo_data;
25   uschar        *interface;
26   uschar        *port;
27   uschar        *protocol;
28   uschar        *dscp;
29   uschar        *serialize_hosts;
30   uschar        *hosts_try_auth;
31   uschar        *hosts_require_auth;
32   uschar        *hosts_try_chunking;
33 #ifdef SUPPORT_DANE
34   uschar        *hosts_try_dane;
35   uschar        *hosts_require_dane;
36   uschar        *dane_require_tls_ciphers;
37 #endif
38   uschar        *hosts_try_fastopen;
39 #ifndef DISABLE_PRDR
40   uschar        *hosts_try_prdr;
41 #endif
42 #ifndef DISABLE_OCSP
43   uschar        *hosts_request_ocsp;
44   uschar        *hosts_require_ocsp;
45 #endif
46   uschar        *hosts_require_tls;
47   uschar        *hosts_avoid_tls;
48   uschar        *hosts_verify_avoid_tls;
49   uschar        *hosts_avoid_pipelining;
50 #ifndef DISABLE_PIPE_CONNECT
51   uschar        *hosts_pipe_connect;
52 #endif
53   uschar        *hosts_avoid_esmtp;
54 #ifndef DISABLE_TLS
55   uschar        *hosts_nopass_tls;
56   uschar        *hosts_noproxy_tls;
57 #endif
58   int           command_timeout;
59   int           connect_timeout;
60   int           data_timeout;
61   int           final_timeout;
62   int           size_addition;
63   int           hosts_max_try;
64   int           hosts_max_try_hardlimit;
65   int                   message_linelength_limit;
66   BOOL          address_retry_include_sender;
67   BOOL          allow_localhost;
68   BOOL          authenticated_sender_force;
69   BOOL          gethostbyname;
70   BOOL          dns_qualify_single;
71   BOOL          dns_search_parents;
72   dnssec_domains dnssec;
73   BOOL          delay_after_cutoff;
74   BOOL          hosts_override;
75   BOOL          hosts_randomize;
76   BOOL          keepalive;
77   BOOL          lmtp_ignore_quota;
78   uschar        *expand_retry_include_ip_address;
79   BOOL          retry_include_ip_address;
80 #ifdef SUPPORT_SOCKS
81   uschar        *socks_proxy;
82 #endif
83 #ifndef DISABLE_TLS
84   uschar        *tls_certificate;
85   uschar        *tls_crl;
86   uschar        *tls_privatekey;
87   uschar        *tls_require_ciphers;
88 # ifndef DISABLE_TLS_RESUME
89   uschar        *tls_resumption_hosts;
90 # endif
91   const uschar  *tls_sni;
92   uschar        *tls_verify_certificates;
93   int           tls_dh_min_bits;
94   BOOL          tls_tempfail_tryclear;
95   uschar        *tls_verify_hosts;
96   uschar        *tls_try_verify_hosts;
97   uschar        *tls_verify_cert_hostnames;
98 #endif
99 #ifdef SUPPORT_I18N
100   uschar        *utf8_downconvert;
101 #endif
102 #ifndef DISABLE_DKIM
103   struct ob_dkim dkim;
104 #endif
105 #ifdef EXPERIMENTAL_ARC
106   uschar        *arc_sign;
107 #endif
108 } smtp_transport_options_block;
109
110 #define SOB (smtp_transport_options_block *)
111
112
113 /* smtp connect context */
114 typedef struct {
115   uschar *              from_addr;
116   address_item *        addrlist;
117
118   smtp_connect_args     conn_args;
119   int                   port;
120
121   BOOL verify:1;
122   BOOL lmtp:1;
123   BOOL smtps:1;
124   BOOL ok:1;
125   BOOL setting_up:1;
126 #ifndef DISABLE_PIPE_CONNECT
127   BOOL early_pipe_ok:1;
128   BOOL early_pipe_active:1;
129 #endif
130   BOOL esmtp:1;
131   BOOL esmtp_sent:1;
132   BOOL pipelining_used:1;
133 #ifndef DISABLE_PRDR
134   BOOL prdr_active:1;
135 #endif
136 #ifdef SUPPORT_I18N
137   BOOL utf8_needed:1;
138 #endif
139   BOOL dsn_all_lasthop:1;
140 #if !defined(DISABLE_TLS) && defined(SUPPORT_DANE)
141   BOOL dane_required:1;
142 #endif
143 #ifndef DISABLE_PIPE_CONNECT
144   BOOL pending_BANNER:1;
145   BOOL pending_EHLO:1;
146 #endif
147   BOOL pending_MAIL:1;
148   BOOL pending_BDAT:1;
149   BOOL RCPT_452:1;
150   BOOL good_RCPT:1;
151   BOOL completed_addr:1;
152   BOOL send_rset:1;
153   BOOL send_quit:1;
154
155   int           max_rcpt;
156   int           cmd_count;
157
158   unsigned      peer_offered;
159   unsigned      avoid_option;
160   uschar *      igquotstr;
161   uschar *      helo_data;
162 #ifdef EXPERIMENTAL_DSN_INFO
163   uschar *      smtp_greeting;
164   uschar *      helo_response;
165 #endif
166 #ifndef DISABLE_PIPE_CONNECT
167   ehlo_resp_precis      ehlo_resp;
168 #endif
169
170   struct timeval        delivery_start;
171   address_item *        first_addr;
172   address_item *        next_addr;
173   address_item *        sync_addr;
174
175   client_conn_ctx       cctx;
176   smtp_inblock          inblock;
177   smtp_outblock         outblock;
178   uschar        buffer[DELIVER_BUFFER_SIZE];
179   uschar        inbuffer[4096];
180   uschar        outbuffer[4096];
181 } smtp_context;
182
183 extern int smtp_setup_conn(smtp_context *, BOOL);
184 extern int smtp_write_mail_and_rcpt_cmds(smtp_context *, int *);
185 extern int smtp_reap_early_pipe(smtp_context *, int *);
186
187
188 /* Data for reading the private options. */
189
190 extern optionlist smtp_transport_options[];
191 extern int smtp_transport_options_count;
192
193 /* Block containing default values. */
194
195 extern smtp_transport_options_block smtp_transport_option_defaults;
196
197 /* The main, init, and closedown entry points for the transport */
198
199 extern BOOL smtp_transport_entry(transport_instance *, address_item *);
200 extern void smtp_transport_init(transport_instance *);
201 extern void smtp_transport_closedown(transport_instance *);
202
203
204
205 #ifdef SUPPORT_SOCKS
206 extern int     socks_sock_connect(host_item *, int, int, uschar *,
207                  transport_instance *, int);
208 #endif
209
210 /* End of transports/smtp.h */