meillo@0: /* smtp_out.h, Copyright (C) Oliver Kurth, meillo@0: * meillo@0: * This program is free software; you can redistribute it and/or modify meillo@0: * it under the terms of the GNU General Public License as published by meillo@0: * the Free Software Foundation; either version 2 of the License, or meillo@0: * (at your option) any later version. meillo@0: * meillo@0: * This program is distributed in the hope that it will be useful, meillo@0: * but WITHOUT ANY WARRANTY; without even the implied warranty of meillo@0: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the meillo@0: * GNU General Public License for more details. meillo@0: * meillo@0: * You should have received a copy of the GNU General Public License meillo@0: * along with this program; if not, write to the Free Software meillo@0: * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. meillo@0: */ meillo@0: meillo@0: #include meillo@0: #include meillo@0: #include meillo@0: #include meillo@0: #include meillo@0: #include meillo@0: meillo@0: #define SMTP_BUF_LEN 1024 meillo@0: #define SMTP_SIZE_ADD 1024 meillo@0: meillo@0: #define SMTP_INITIAL_TIMEOUT 5*60 meillo@0: #define SMTP_CMD_TIMEOUT 5*60 meillo@0: #define SMTP_DATA_TIMEOUT 5*60 meillo@0: #define SMTP_FINAL_TIMEOUT 10*60 meillo@0: meillo@0: typedef meillo@0: enum _smtp_error{ meillo@0: smtp_ok = 0, /* mail was delivered to at least one recpient */ meillo@0: smtp_trylater, /* server responded with 4xx */ meillo@0: smtp_fail, /* server responded with 5xx */ meillo@0: smtp_timeout, /* connection timed out */ meillo@0: smtp_eof, /* got unexpected EOF */ meillo@0: smtp_syntax, /* unexpected response */ meillo@0: smtp_cancel /* we gave up (eg. size) */ meillo@0: } smtp_error; meillo@0: meillo@0: meillo@0: typedef meillo@0: struct _smtp_base{ meillo@0: FILE *in; meillo@0: FILE *out; meillo@0: meillo@0: gint sock; meillo@0: gint dup_sock; meillo@0: meillo@0: gchar *remote_host; meillo@0: gchar *helo_name; meillo@0: meillo@0: gchar *buffer; meillo@0: gint last_code; meillo@0: meillo@0: gboolean use_esmtp; meillo@0: gboolean use_size; meillo@0: gboolean use_pipelining; meillo@0: gboolean use_auth; meillo@0: meillo@0: gint max_size; meillo@0: meillo@0: gchar **auth_names; meillo@0: meillo@0: gchar *auth_name; meillo@0: gchar *auth_login; meillo@0: gchar *auth_secret; meillo@0: meillo@0: smtp_error error; meillo@0: meillo@0: } smtp_base; meillo@0: meillo@0: gchar *set_heloname(smtp_base *psb, gchar *default_name, gboolean do_correct); meillo@0: gboolean set_auth(smtp_base *psb, gchar *name, gchar *login, gchar *secret); meillo@0: void destroy_smtpbase(smtp_base *psb); meillo@0: smtp_base *smtp_out_open(gchar *host, gint port, GList *resolve_list); meillo@0: smtp_base *smtp_out_open_child(gchar *cmd); meillo@0: gboolean smtp_out_rset(smtp_base *psb); meillo@0: gboolean smtp_out_init(smtp_base *psb); meillo@0: gint smtp_out_msg(smtp_base *psb, meillo@0: message *msg, address *return_path, meillo@0: GList *rcpt_list, GList *hdr_list); meillo@0: gboolean smtp_out_quit(smtp_base *psb); meillo@0: meillo@0: gint smtp_deliver(gchar *host, gint port, GList *resolve_list, meillo@0: message *msg, meillo@0: address *return_path, meillo@0: GList *rcpt_list);