static SMTP_SESSION *smtp_reuse_common(SMTP_STATE *state, int fd, const char *label) { const char *myname = "smtp_reuse_common"; SMTP_ITERATOR *iter = state->iterator; SMTP_SESSION *session; /* * Can't happen. Both smtp_reuse_nexthop() and smtp_reuse_addr() decline * the request when the TLS policy is not TLS_LEV_NONE. */ #ifdef USE_TLS if (state->tls->level > TLS_LEV_NONE) msg_panic("%s: unexpected plain-text cached session to %s", myname, label); #endif /* * Re-activate the SMTP_SESSION object. */ session = smtp_session_activate(fd, state->iterator, state->dest_prop, state->endp_prop); if (session == 0) { msg_warn("%s: bad cached session attribute for %s", myname, label); (void) close(fd); return (0); } state->session = session; session->state = state; #ifdef USE_TLS session->tls = state->tls; /* TEMPORARY */ #endif /* * Send an RSET probe to verify that the session is still good. */ if (smtp_rset(state) < 0 || (session->features & SMTP_FEATURE_RSET_REJECTED) != 0) { smtp_session_free(session); return (state->session = 0); } /* * Avoid poor performance when TCP MSS > VSTREAM_BUFSIZE. */ vstream_tweak_sock(session->stream); /* * Update the list of used cached addresses. */ htable_enter(state->cache_used, STR(iter->addr), (char *) 0); return (session); }
static gboolean smtp_transport_send_to_sync (CamelTransport *transport, CamelMimeMessage *message, CamelAddress *from, CamelAddress *recipients, gboolean *out_sent_message_saved, GCancellable *cancellable, GError **error) { CamelSmtpTransport *smtp_transport = CAMEL_SMTP_TRANSPORT (transport); CamelInternetAddress *cia; gboolean has_8bit_parts; const gchar *addr; gint i, len; smtp_debug_print_server_name (CAMEL_SERVICE (transport), "Sending with"); if (!smtp_transport->connected) { g_set_error ( error, CAMEL_SERVICE_ERROR, CAMEL_SERVICE_ERROR_NOT_CONNECTED, _("Cannot send message: service not connected.")); return FALSE; } if (!camel_internet_address_get (CAMEL_INTERNET_ADDRESS (from), 0, NULL, &addr)) { g_set_error ( error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, _("Cannot send message: sender address not valid.")); return FALSE; } camel_operation_push_message (cancellable, _("Sending message")); /* find out if the message has 8bit mime parts */ has_8bit_parts = camel_mime_message_has_8bit_parts (message); /* If the connection needs a ReSET, then do so */ if (smtp_transport->need_rset && !smtp_rset (smtp_transport, cancellable, error)) { camel_operation_pop_message (cancellable); return FALSE; } smtp_transport->need_rset = FALSE; /* rfc1652 (8BITMIME) requires that you notify the ESMTP daemon that * you'll be sending an 8bit mime message at "MAIL FROM:" time. */ if (!smtp_mail ( smtp_transport, addr, has_8bit_parts, cancellable, error)) { camel_operation_pop_message (cancellable); return FALSE; } len = camel_address_length (recipients); if (len == 0) { g_set_error ( error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, _("Cannot send message: no recipients defined.")); camel_operation_pop_message (cancellable); smtp_transport->need_rset = TRUE; return FALSE; } cia = CAMEL_INTERNET_ADDRESS (recipients); for (i = 0; i < len; i++) { gchar *enc; if (!camel_internet_address_get (cia, i, NULL, &addr)) { g_set_error ( error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, _("Cannot send message: " "one or more invalid recipients")); camel_operation_pop_message (cancellable); smtp_transport->need_rset = TRUE; return FALSE; } enc = camel_internet_address_encode_address (NULL, NULL, addr); if (!smtp_rcpt (smtp_transport, enc, cancellable, error)) { g_free (enc); camel_operation_pop_message (cancellable); smtp_transport->need_rset = TRUE; return FALSE; } g_free (enc); } if (!smtp_data (smtp_transport, message, cancellable, error)) { camel_operation_pop_message (cancellable); smtp_transport->need_rset = TRUE; return FALSE; } camel_operation_pop_message (cancellable); return TRUE; }
bool smtp_client::reset() { return smtp_rset(client_) == 0 ? true : false; }