1 /* GNU Mailutils -- a suite of utilities for electronic mail 2 Copyright (C) 2010-2021 Free Software Foundation, Inc. 3 4 This library is free software; you can redistribute it and/or modify 5 it under the terms of the GNU Lesser General Public License as published by 6 the Free Software Foundation; either version 3, or (at your option) 7 any later version. 8 9 This library is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU Lesser General Public License for more details. 13 14 You should have received a copy of the GNU Lesser General Public License 15 along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ 16 17 #ifndef _MAILUTILS_SMTP_H 18 # define _MAILUTILS_SMTP_H 19 20 # include <sys/types.h> 21 # include <sys/socket.h> 22 # include <mailutils/types.h> 23 24 typedef struct _mu_smtp *mu_smtp_t; 25 26 enum 27 { 28 MU_SMTP_PARAM_DOMAIN, 29 MU_SMTP_PARAM_USERNAME, 30 MU_SMTP_PARAM_PASSWORD, 31 MU_SMTP_PARAM_SERVICE, 32 MU_SMTP_PARAM_REALM, 33 MU_SMTP_PARAM_HOST, 34 MU_SMTP_PARAM_URL 35 }; 36 37 #define MU_SMTP_MAX_PARAM (MU_SMTP_PARAM_URL+1) 38 39 int mu_smtp_create (mu_smtp_t *); 40 void mu_smtp_destroy (mu_smtp_t *); 41 int mu_smtp_set_carrier (mu_smtp_t smtp, mu_stream_t str); 42 int mu_smtp_get_carrier (mu_smtp_t smtp, mu_stream_t *pcarrier); 43 44 int mu_smtp_open (mu_smtp_t); 45 int mu_smtp_response (mu_smtp_t smtp); 46 int mu_smtp_write (mu_smtp_t smtp, const char *fmt, ...) MU_PRINTFLIKE(2,3); 47 48 int mu_smtp_replcode (mu_smtp_t smtp, char *buf); 49 int mu_smtp_sget_reply (mu_smtp_t smtp, const char **pbuf); 50 int mu_smtp_get_reply_iterator (mu_smtp_t smtp, mu_iterator_t *pitr); 51 52 int mu_smtp_cmd (mu_smtp_t smtp, int argc, char **argv); 53 54 #define MU_SMTP_TRACE_CLR 0 55 #define MU_SMTP_TRACE_SET 1 56 #define MU_SMTP_TRACE_QRY 2 57 int mu_smtp_trace (mu_smtp_t smtp, int op); 58 int mu_smtp_trace_mask (mu_smtp_t smtp, int op, int lev); 59 60 int mu_smtp_disconnect (mu_smtp_t smtp); 61 int mu_smtp_ehlo (mu_smtp_t smtp); 62 int mu_smtp_set_param (mu_smtp_t smtp, int code, const char *val); 63 int mu_smtp_get_param (mu_smtp_t smtp, int code, const char **param); 64 int mu_smtp_test_param (mu_smtp_t smtp, int pcode); 65 int mu_smtp_set_url (mu_smtp_t smtp, mu_url_t url); 66 int mu_smtp_get_url (mu_smtp_t smtp, mu_url_t *purl); 67 int mu_smtp_set_secret (mu_smtp_t smtp, mu_secret_t secret); 68 int mu_smtp_get_secret (mu_smtp_t smtp, mu_secret_t *secret); 69 70 int mu_smtp_capa_test (mu_smtp_t smtp, const char *capa, const char **pret); 71 int mu_smtp_capa_iterator (mu_smtp_t smtp, mu_iterator_t *itr); 72 int mu_smtp_starttls (mu_smtp_t smtp); 73 74 int mu_smtp_mail_basic (mu_smtp_t smtp, const char *email, 75 const char *fmt, ...) MU_PRINTFLIKE(3,4); 76 int mu_smtp_rcpt_basic (mu_smtp_t smtp, const char *email, 77 const char *fmt, ...) MU_PRINTFLIKE(3,4); 78 79 int mu_smtp_data (mu_smtp_t smtp, mu_stream_t *pstream); 80 int mu_smtp_send_stream (mu_smtp_t smtp, mu_stream_t str); 81 int mu_smtp_dot (mu_smtp_t smtp); 82 int mu_smtp_rset (mu_smtp_t smtp); 83 int mu_smtp_quit (mu_smtp_t smtp); 84 85 int mu_smtp_auth (mu_smtp_t smtp); 86 87 int mu_smtp_add_auth_mech (mu_smtp_t smtp, const char *mech); 88 int mu_smtp_clear_auth_mech (mu_smtp_t smtp); 89 int mu_smtp_add_auth_mech_list (mu_smtp_t smtp, mu_list_t list); 90 int mu_smtp_mech_select (mu_smtp_t smtp, const char **pmech); 91 92 #endif 93