From ecfb69d75cd29975df94500fa5bd062f4e871d23 Mon Sep 17 00:00:00 2001 From: Sam Roberts Date: Thu, 11 Apr 2002 03:10:42 +0000 Subject: A stub mail.remote. It is waiting on completion of the smtp mailer_t. --- mail.remote/Makefile.am | 8 ++++ mail.remote/mail.remote.c | 119 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 127 insertions(+) create mode 100644 mail.remote/Makefile.am create mode 100644 mail.remote/mail.remote.c (limited to 'mail.remote') diff --git a/mail.remote/Makefile.am b/mail.remote/Makefile.am new file mode 100644 index 000000000..e6c45de5e --- /dev/null +++ b/mail.remote/Makefile.am @@ -0,0 +1,8 @@ +AUTOMAKE_OPTIONS = ../lib/ansi2knr +INCLUDES =-I$(srcdir) -I$(top_srcdir)/lib -I$(top_srcdir)/include -I$(top_srcdir)/libmu_scm + +libexec_PROGRAMS = mail.remote +mail_remote_SOURCES = mail.remote.c mail.remote.h + +mail_remote_LDADD = ../mailbox/libmailbox.la ../lib/libmailutils.la + diff --git a/mail.remote/mail.remote.c b/mail.remote/mail.remote.c new file mode 100644 index 000000000..f2db09cfe --- /dev/null +++ b/mail.remote/mail.remote.c @@ -0,0 +1,119 @@ +/* FIXME: the will no really work until I've completed the smtp mailer_t. + Until then, its just place holder code. + */ + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#define C(X) {int e; if((e = X) != 0) { \ + fprintf(stderr, "%s failed: %s\n", #X, mu_errstring(e)); \ + exit(1); } } + +const char USAGE[] = + "usage: mailer [-hd] [-m mailer] [-f from] [to]..." + ; +const char HELP[] = + " -h print this helpful message\n" + " -m a mailer URL (default is \"sendmail:\")\n" + " -f the envelope from address (default is from user environment)\n" + " to a list of envelope to addresses (default is from message)\n" + "\n" + "An RFC2822 formatted message is read from stdin and delivered using\n" + "the mailer.\n" + ; + +int +main (int argc, char *argv[]) +{ + int opt; + int optdebug = 0; + char* optmailer = "sendmail:"; + char* optfrom = 0; + + stream_t in = 0; + message_t msg = 0; + mailer_t mailer = 0; + address_t from = 0; + address_t to = 0; + + while((opt = getopt(argc, argv, "hdm:f:")) != -1) + { + switch(opt) + { + case 'h': + printf("%s\n%s", USAGE, HELP); + return 0; + case 'd': + optdebug++; + break; + case 'm': + optmailer = optarg; + break; + case 'f': + optfrom = optarg; + break; + default: + fprintf(stderr, "%s\n", USAGE); + break; + } + } + + /* Register mailers. */ + { + list_t bookie; + registrar_get_list (&bookie); + C( list_append (bookie, smtp_record) ) + C( list_append (bookie, sendmail_record) ) + } + + if(optfrom) + { + C( address_create(&from, optfrom) ) + } + + if(argv[optind]) + { + char** av = argv + optind; + + C( address_createv(&to, (const char**) av, -1) ) + } + + C( stdio_stream_create(&in, stdin, 0) ) + + C( stream_open(in) ) + + C( message_create (&msg, NULL) ) + + C( message_set_stream(msg, in, NULL) ) + + C( mailer_create(&mailer, optmailer) ) + + if(optdebug) + { + mu_debug_t debug; + mailer_get_debug (mailer, &debug); + mu_debug_set_level (debug, MU_DEBUG_TRACE | MU_DEBUG_PROT); + } + + C( mailer_open(mailer, 0) ) + + C( mailer_send_message(mailer, msg, from, to) ) + + return 0; +} + -- cgit v1.2.1