}
}
+void smtp_client_abort(struct smtp_client **_client)
+{
+ struct smtp_client *client = *_client;
+
+ *_client = NULL;
+
+ o_stream_ignore_last_errors(client->output);
+ if (!client->use_smtp) {
+ if (client->pid != (pid_t)-1)
+ (void)kill(client->pid, SIGTERM);
+ (void)smtp_client_deinit_sendmail(client);
+ } else {
+ o_stream_destroy(&client->output);
+ pool_unref(&client->pool);
+ }
+}
+
int smtp_client_deinit(struct smtp_client *client, const char **error_r)
{
int ret;
/* the mail has been written to a file. now actually send it. */
ret = smtp_client_send_flush(client, error_r);
- o_stream_destroy(&client->output);
- pool_unref(&client->pool);
+ smtp_client_abort(&client);
return ret;
}
/* Get an output stream where the message can be written to. The recipients
must already be added before calling this. */
struct ostream *smtp_client_send(struct smtp_client *client);
+void smtp_client_abort(struct smtp_client **client);
/* Returns 1 on success, 0 on permanent failure (e.g. invalid destination),
-1 on temporary failure. */
int smtp_client_deinit(struct smtp_client *client, const char **error_r);