/* -*- c -*-
mzmail.c, part of:
muttzilla v0.40
Copyright (C) 1999-2000 Brian D. Winters
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "muttzilla.h"
#include <stdio.h>
#include <unistd.h>
/* creates an instance of the selected mailer passing the specified arguments */
int mzspawn_mail(mailparms *parms) {
char *args[8] = { mz_mailprog, "", "", "", "", "", "", NULL };
tempfile_info *tf;
if(parms) {
if(parms->to)
args[1] = parms->to;
else
args[1] = ".";
if(parms->cc)
args[2] = parms->cc;
if(parms->bcc)
args[3] = parms->bcc;
if(parms->subject)
args[4] = parms->subject;
if(parms->body) {
tf = open_tempfile();
if(tf) {
if(fputs(parms->body, tf->fp) != EOF)
args[5] = tf->filename;
if(fclose(tf->fp) == 0)
tf->fp = NULL;
if(close(tf->fd) == 0)
tf->fd = -1;
}
}
if(parms->org)
args[6] = parms->org;
}
return mzspawn(args);
}
syntax highlighted by Code2HTML, v. 0.9.1