bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Boschstruct smtp_client *smtp_client_init(const struct smtp_client_settings *set)
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch pool = pool_alloconly_create("smtp client", 1024);
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch client->set.my_hostname = p_strdup(pool, set->my_hostname);
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch client->set.rawlog_dir = p_strdup_empty(pool, set->rawlog_dir);
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch ssl_iostream_settings_dup(client->pool, set->ssl);
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch client->set.master_user = p_strdup_empty(pool, set->master_user);
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch client->set.username = p_strdup_empty(pool, set->username);
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch client->set.connect_timeout_msecs = set->connect_timeout_msecs != 0 ?
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch client->set.command_timeout_msecs = set->command_timeout_msecs != 0 ?
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch client->set.max_reply_size = set->max_reply_size != 0 ?
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch set->max_reply_size : SMTP_DEFAULT_MAX_REPLY_SIZE;
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch client->set.max_data_chunk_size = set->max_data_chunk_size != 0 ?
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch set->max_data_chunk_size : SMTP_DEFAULT_MAX_DATA_CHUNK_SIZE;
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch client->set.max_data_chunk_pipeline = set->max_data_chunk_pipeline != 0 ?
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch set->max_data_chunk_pipeline : SMTP_DEFAULT_MAX_DATA_CHUNK_PIPELINE;
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch client->set.socket_send_buffer_size = set->socket_send_buffer_size;
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch client->set.socket_recv_buffer_size = set->socket_recv_buffer_size;
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch client->set.proxy_data.source_ip = set->proxy_data.source_ip;
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch client->set.proxy_data.source_port = set->proxy_data.source_port;
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch client->set.proxy_data.ttl_plus_1 = set->proxy_data.ttl_plus_1;
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch client->set.proxy_data.timeout_secs = set->proxy_data.timeout_secs;
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch client->set.proxy_data.helo = p_strdup_empty(pool, set->proxy_data.helo);
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch client->set.proxy_data.login = p_strdup_empty(pool, set->proxy_data.login);
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch client->conn_list = smtp_client_connection_list_init();
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Boschvoid smtp_client_deinit(struct smtp_client **_client)
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Boschvoid smtp_client_switch_ioloop(struct smtp_client *client)
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch struct connection *_conn = client->conn_list->connections;
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch /* move connections */
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Boschint smtp_client_init_ssl_ctx(struct smtp_client *client, const char **error_r)
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch *error_r = "Requested SSL connection, but no SSL settings given";
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch if (ssl_iostream_client_context_cache_get(client->set.ssl,
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch *error_r = t_strdup_printf("Couldn't initialize SSL context: %s",
b3888944586654b4aa069e0db31f998e0ed8b414Stephan Bosch// FIXME: Implement smtp_client_run()