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 as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 * Tom Cort <tom.cort@state.vt.us>
21 * Matt Gagne <matt.gagne@state.vt.us>
25 #include <jwsmtp/jwsmtp.h>
26 #include <libdaemon/dlog.h>
33 * Returns a banner to go at the bottom of e-mails. Remember to delete it when done.
34 * @return footer string
36 std::string
* smtp_get_banner()
39 * " (o_ Powered by: inoclam v1.0 (Bender)\n"
40 * " //\ Homepage: http://www.inoclam.org/\n"
41 * " V_/_ Author: Vermont Department of Taxes\n"
45 banner
= new std::string();
46 banner
->append(" (o_ Powered by inoclam v");
48 std::string
* version
;
49 version
= new std::string(VERSION
);
50 banner
->append(version
->c_str());
55 std::string
* codename
;
56 codename
= new std::string(CODENAME
);
57 banner
->append(codename
->c_str());
60 banner
->append(")\n");
62 banner
->append(" //\\ Developed by the Vermont Department of Taxes\n");
63 banner
->append(" V_/_ Project Homepage: http://www.inoclam.org/\n");
69 * Returns an RFC 2822 Compliant Date String
72 std::string
* smtp_get_timestamp()
81 timestamp
= (char *) malloc(sizeof(char) * 41);
83 daemon_log(LOG_ERR
, "malloc() failed!");
87 memset(timestamp
, '\0', 41); /* RFC 2822 Date */
88 strftime(timestamp
, 40, "%a, %d %b %Y %H:%M:%S", tm
);
91 tstamp
= new std::string(timestamp
);
104 void smtp_send(char *subject
, std::string
* body
, config
* conf
)
106 char *smtp_host
= conf
->getHost();
107 int smtp_port
= conf
->getPort();
108 char *smtp_from
= conf
->getFrom();
109 const char *smtp_body
= body
->c_str();
111 if (smtp_host
== NULL
|| smtp_from
== NULL
|| smtp_port
< 1 || smtp_port
> 65535 || subject
== NULL
|| smtp_body
== NULL
) {
112 daemon_log(LOG_INFO
, "Incomplete Configuration or Message -- Not Sending E-Mail");
116 for (std::list
< char *>::iterator itr
= conf
->getTo()->begin(); itr
!= conf
->getTo()->end(); ++itr
) {
120 daemon_log(LOG_INFO
, "Mailing '%s' ", smtp_to
);
122 /* Why are there no C libraries for sending mail that are this simple? */
123 jwsmtp::mailer
* mail
;
124 mail
= new jwsmtp::mailer(smtp_to
, smtp_from
, subject
, smtp_body
, smtp_host
, smtp_port
, false);