1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
/*
This file is part of SLRN.
Copyright (c) 1994, 1999, 2007-2009 John E. Davis <jed@jedsoft.org>
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 "slrnfeat.h"
#include <stdio.h>
#include <ssdef.h>
#include <string.h>
#include "vms.h"
#include "vmsmail.h"
extern int mail$send_add_bodypart ();
extern int mail$send_begin ();
extern int mail$send_add_attribute ();
extern int mail$send_add_address ();
extern int mail$send_message ();
extern int mail$send_end ();
static void fill_struct(Mail_Type *m, int act, char *s)
{
m->code = act;
m->buflen = strlen(s);
m->addr = (long) s;
m->junk = m->ret = 0;
}
/* to might be a comma separated list--- parse it too */
int vms_send_mail(char *to, char *subj, char *file)
{
Mail_Type mt0, mt;
int context = 0;
char *p;
mt0.code = mt0.buflen = mt0.addr = mt0.ret = mt0.junk = 0;
if (SS$_NORMAL != mail$send_begin(&context, &mt0, &mt0))
{
return(0);
}
#if 0
fill_struct(&mt, MAIL$_SEND_TO_LINE, to);
if (SS$_NORMAL != mail$send_add_attribute(&context, &mt, &mt0))
{
return(0);
}
fill_struct(&mt, MAIL$_SEND_USERNAME, to);
if (SS$_NORMAL != mail$send_add_address(&context, &mt, &mt0))
{
return(0);
}
#endif
while (1)
{
while (*to && ((*to <= ' ') || (*to == ','))) to++;
if (*to == 0) break;
p = to;
while ((*p > ' ') && (*p != ',')) p++;
mt.code = MAIL$_SEND_TO_LINE;
mt.buflen = p - to;
mt.ret = mt.junk = 0;
mt.addr = (long) to;
if (SS$_NORMAL != mail$send_add_attribute(&context, &mt, &mt0))
{
return(0);
}
mt.code = MAIL$_SEND_USERNAME;
mt.buflen = p - to;
mt.ret = mt.junk = 0;
mt.addr = (long) to;
if (SS$_NORMAL != mail$send_add_address(&context, &mt, &mt0))
{
return(0);
}
to = p;
}
fill_struct(&mt, MAIL$_SEND_SUBJECT, subj);
if (SS$_NORMAL != mail$send_add_attribute(&context, &mt, &mt0))
{
return(0);
}
fill_struct(&mt, MAIL$_SEND_FILENAME, file);
if (SS$_NORMAL != mail$send_add_bodypart(&context, &mt, &mt0))
{
return(0);
}
if (SS$_NORMAL != mail$send_message(&context, &mt0, &mt0))
{
return(0);
}
if (SS$_NORMAL != mail$send_end(&context, &mt0, &mt0))
{
return(0);
}
return(1);
}
|