2 * inoclam - Inotify+ClamAV virus scanner
3 * Copyright (C) 2007 Vermont Department of Taxes
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 * Tom Cort <tom.cort@state.vt.us>
20 * Matt Gagne <matt.gagne@state.vt.us>
24 #include <jwsmtp/jwsmtp.h>
25 #include <libdaemon/dlog.h>
32 * Returns a banner to go at the bottom of e-mails. Remember to delete it when done.
33 * @return footer string
35 std::string
* smtp_get_banner()
38 * " (o_ Powered by: inoclam v1.0 (Bender)\n"
39 * " //\ Homepage: http://www.inoclam.org/\n"
40 * " V_/_ Author: Vermont Department of Taxes\n"
44 banner
= new std::string();
45 banner
->append(" (o_ Powered by inoclam v");
47 std::string
* version
;
48 version
= new std::string(VERSION
);
49 banner
->append(version
->c_str());
54 std::string
* codename
;
55 codename
= new std::string(CODENAME
);
56 banner
->append(codename
->c_str());
59 banner
->append(")\n");
61 banner
->append(" //\\ Developed by the Vermont Department of Taxes\n");
62 banner
->append(" V_/_ Project Homepage: http://www.inoclam.org/\n");
68 * Returns an RFC 2822 Compliant Date String
71 std::string
* smtp_get_timestamp()
80 timestamp
= (char *) malloc(sizeof(char) * 41);
82 daemon_log(LOG_ERR
, "malloc() failed!");
86 memset(timestamp
, '\0', 41); /* RFC 2822 Date */
87 strftime(timestamp
, 40, "%a, %d %b %Y %H:%M:%S", tm
);
90 tstamp
= new std::string(timestamp
);
103 void smtp_send(char *subject
, std::string
* body
, config
* conf
)
105 char *smtp_host
= conf
->getHost();
106 int smtp_port
= conf
->getPort();
107 char *smtp_from
= conf
->getFrom();
108 const char *smtp_body
= body
->c_str();
110 if (smtp_host
== NULL
|| smtp_from
== NULL
|| smtp_port
< 1 || smtp_port
> 65535 || subject
== NULL
|| smtp_body
== NULL
) {
111 daemon_log(LOG_INFO
, "Incomplete Configuration or Message -- Not Sending E-Mail");
115 for (std::list
< char *>::iterator itr
= conf
->getTo()->begin(); itr
!= conf
->getTo()->end(); ++itr
) {
119 daemon_log(LOG_INFO
, "Mailing '%s' ", smtp_to
);
121 /* Why are there no C libraries for sending mail that are this simple? */
122 jwsmtp::mailer
* mail
;
123 mail
= new jwsmtp::mailer(smtp_to
, smtp_from
, subject
, smtp_body
, smtp_host
, smtp_port
, false);