aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/sendmail/camel-sendmail-transport.c
diff options
context:
space:
mode:
Diffstat (limited to 'camel/providers/sendmail/camel-sendmail-transport.c')
-rw-r--r--camel/providers/sendmail/camel-sendmail-transport.c227
1 files changed, 0 insertions, 227 deletions
diff --git a/camel/providers/sendmail/camel-sendmail-transport.c b/camel/providers/sendmail/camel-sendmail-transport.c
deleted file mode 100644
index 3facc42676..0000000000
--- a/camel/providers/sendmail/camel-sendmail-transport.c
+++ /dev/null
@@ -1,227 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* camel-sendmail-transport.c: Sendmail-based transport class. */
-
-/*
- *
- * Author :
- * Dan Winship <danw@helixcode.com>
- *
- * Copyright 2000 Helix Code, Inc. (http://www.helixcode.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-#include <config.h>
-
-#include <errno.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <string.h>
-
-#include "camel-sendmail-transport.h"
-#include "camel-mime-message.h"
-#include "camel-data-wrapper.h"
-#include "camel-stream-fs.h"
-#include "camel-exception.h"
-
-static char *get_name (CamelService *service, gboolean brief);
-
-static gboolean _can_send (CamelTransport *transport, CamelMedium *message);
-static gboolean _send (CamelTransport *transport, CamelMedium *message,
- CamelException *ex);
-static gboolean _send_to (CamelTransport *transport, CamelMedium *message,
- GList *recipients, CamelException *ex);
-
-
-static void
-camel_sendmail_transport_class_init (CamelSendmailTransportClass *camel_sendmail_transport_class)
-{
- CamelTransportClass *camel_transport_class =
- CAMEL_TRANSPORT_CLASS (camel_sendmail_transport_class);
- CamelServiceClass *camel_service_class =
- CAMEL_SERVICE_CLASS (camel_sendmail_transport_class);
-
- /* virtual method overload */
- camel_service_class->get_name = get_name;
-
- camel_transport_class->can_send = _can_send;
- camel_transport_class->send = _send;
- camel_transport_class->send_to = _send_to;
-}
-
-GtkType
-camel_sendmail_transport_get_type (void)
-{
- static GtkType camel_sendmail_transport_type = 0;
-
- if (!camel_sendmail_transport_type) {
- GtkTypeInfo camel_sendmail_transport_info =
- {
- "CamelSendmailTransport",
- sizeof (CamelSendmailTransport),
- sizeof (CamelSendmailTransportClass),
- (GtkClassInitFunc) camel_sendmail_transport_class_init,
- (GtkObjectInitFunc) NULL,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
- };
-
- camel_sendmail_transport_type = gtk_type_unique (CAMEL_TRANSPORT_TYPE, &camel_sendmail_transport_info);
- }
-
- return camel_sendmail_transport_type;
-}
-
-
-static gboolean
-_can_send (CamelTransport *transport, CamelMedium *message)
-{
- return CAMEL_IS_MIME_MESSAGE (message);
-}
-
-
-static gboolean
-_send_internal (CamelMedium *message, char **argv, CamelException *ex)
-{
- int fd[2], nullfd, wstat;
- sigset_t mask, omask;
- CamelStream *out;
- pid_t pid;
-
- g_assert (CAMEL_IS_MIME_MESSAGE (message));
-
- if (pipe (fd) == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- "Could not create pipe to sendmail: "
- "%s: mail not sent",
- g_strerror (errno));
- return FALSE;
- }
-
- /* Block SIGCHLD so the calling application doesn't notice
- * sendmail exiting before we do.
- */
- sigemptyset (&mask);
- sigaddset (&mask, SIGCHLD);
- sigprocmask (SIG_BLOCK, &mask, &omask);
-
- pid = fork ();
- switch (pid) {
- case -1:
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- "Could not fork sendmail: "
- "%s: mail not sent", g_strerror (errno));
- sigprocmask (SIG_SETMASK, &omask, NULL);
- return FALSE;
-
- case 0:
- /* Child process */
- nullfd = open ("/dev/null", O_RDWR);
- dup2 (fd[0], STDIN_FILENO);
- dup2 (nullfd, STDOUT_FILENO);
- dup2 (nullfd, STDERR_FILENO);
- close (nullfd);
- close (fd[1]);
-
- execv (SENDMAIL_PATH, argv);
- _exit (255);
- }
-
- /* Parent process. Write the message out. */
- close (fd[0]);
- out = camel_stream_fs_new_with_fd (fd[1]);
- if (camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), out) == -1
- || camel_stream_close(out) == -1) {
- gtk_object_unref (GTK_OBJECT (out));
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- "Could not send message: %s",
- strerror(errno));
- return FALSE;
- }
- gtk_object_unref (GTK_OBJECT (out));
-
- /* Wait for sendmail to exit. */
- while (waitpid (pid, &wstat, 0) == -1 && errno == EINTR)
- ;
- sigprocmask (SIG_SETMASK, &omask, NULL);
-
- if (!WIFEXITED (wstat)) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- "sendmail exited with signal %s: "
- "mail not sent.",
- g_strsignal (WTERMSIG (wstat)));
- return FALSE;
- } else if (WEXITSTATUS (wstat) != 0) {
- if (WEXITSTATUS (wstat) == 255) {
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- "Could not execute "
- SENDMAIL_PATH ": mail not sent.");
- } else {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- "sendmail exited with status "
- "%d: mail not sent.",
- WEXITSTATUS (wstat));
- }
- return FALSE;
- }
-
- return TRUE;
-}
-
-static gboolean
-_send_to (CamelTransport *transport, CamelMedium *message,
- GList *recipients, CamelException *ex)
-{
- GList *r;
- char **argv;
- int i, len;
- gboolean status;
-
- len = g_list_length (recipients);
- argv = g_malloc ((len + 4) * sizeof (char *));
- argv[0] = "sendmail";
- argv[1] = "-i";
- argv[2] = "--";
-
- for (i = 1, r = recipients; i <= len; i++, r = r->next)
- argv[i + 2] = r->data;
- argv[i + 2] = NULL;
-
- status = _send_internal (message, argv, ex);
- g_free (argv);
- return status;
-}
-
-static gboolean
-_send (CamelTransport *transport, CamelMedium *message,
- CamelException *ex)
-{
- char *argv[4] = { "sendmail", "-t", "-i", NULL };
-
- return _send_internal (message, argv, ex);
-}
-
-static char *
-get_name (CamelService *service, gboolean brief)
-{
- if (brief)
- return g_strdup ("sendmail");
- else
- return g_strdup ("Mail delivery via the sendmail program");
-}
aph'>* All dictionaries can be installed separately:thierry2006-07-154-7/+15 * - convert to OPTIONSitetcu2006-07-132-94/+25 * Update MASTER_SITES and WWWitetcu2006-06-142-2/+2 * Update to 20060519miwi2006-06-073-77/+88 * Update to KDE 3.5.3lofi2006-06-064-22/+146 * - Rename portspav2006-05-281-1/+1 * Update to KOffice 1.5.1lofi2006-05-276-12/+12 * Remove USE_REINPLACE from all categories starting with Pedwin2006-05-134-5/+0 * Update to KOffice 1.5.0lofi2006-04-299-15/+24 * - Fix broken WWWmnag2006-04-291-1/+1 * [maint update] polish/ekg2 fix 4.x compilation and upgradeedwin2006-04-052-4/+5 * - Mark broken on 4.Xpav2006-04-041-1/+7 * Text-based Gadu-Gadu (and other) client for Unix-like systems.pav2006-04-025-0/+150 * Disable OpenSSL support. This is not a big deal since gadugadu serversmarcus2006-04-021-1/+2 * Update to KDE 3.5.2lofi2006-03-314-128/+192 * Bump PORTREVISION on glib12/gtk12 consumer ports to ease the upgrade path.ade2006-03-071-1/+1 * Conversion to a single libtool environment.ade2006-02-232-19/+19 * Update to KDE 3.5.1.lofi2006-02-014-18/+162 * BROKEN: Needs to be converted to use OPTIONS. The home-brewed configurekris2006-01-281-0/+2 * SHA256ifyedwin2006-01-247-0/+7 * Replace ugly "@unexec rmdir %D... 2>/dev/null || true" with @dirrmtryedwin2006-01-222-15/+15 * A library used by many Instant Messangers that can communicate using thepav2006-01-155-0/+43 * Update to KDE 3.5.0lofi2006-01-094-110/+152 * Chase the dbus shared lib version.marcus2006-01-011-1/+1 * - Update to version 0.4.3az2005-12-152-4/+4 * Remove expired ports.lawrance2005-12-157-136/+0 * - Respect X11BASE\LOCALBASEaz2005-12-062-59/+71 * - Change mainter email addressaz2005-11-263-2/+3 * - Change maintainer email address.az2005-11-263-4/+5 * - Add SHA256pav2005-11-262-0/+2 * - Add SHA256sem2005-11-181-0/+1 * Mass-conversion to the USE_AUTOTOOLS New World Order. The code presentade2005-11-151-1/+1 * - Update to 1.6pav2005-11-122-7/+7 * - Update to 20051022pav2005-11-103-16/+22 * - Change second category to be net-impav2005-11-104-4/+4 * Move instant messaging related ports to newly created net-im category:pav2005-11-091-1/+1 * Update to KDE 3.4.3 / KOffice 1.4.2lofi2005-11-0513-16/+156 * Bump PORTREVISION to chase the glib20 shared library update.marcus2005-11-052-1/+2 * Respect LOCALBASE and X11BASE.lawrance2005-11-011-0/+2 * Remove all the secondary port of editors/ooodict-allmaho2005-11-012-24/+0 * BROKEN: Size mismatchkris2005-10-291-0/+2 * Add missing patch filesedwin2005-10-232-0/+68 * [MAINTAINER] polish/pl-kadu: update to 0.4.2edwin2005-10-235-135/+11 * - Update to 2.2.8pav2005-10-089-92/+215 * Add USE_OPENSSL and a simple post-patch to fix build on 4.xlawrance2005-09-141-2/+8 * Fix pkg-plistlawrance2005-09-081-0/+2 * - Update to 0.4.1lawrance2005-09-055-442/+625 * Mark deprecated (expires in 3 months). This version of sms is outdatedlawrance2005-08-301-0/+3 * Fix index build by moving openoffice.org-1.1 ports.maho2005-08-29