2 * inoclam - Inotify+ClamAV virus scanner
3 * Copyright (C) 2007, 2008 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
21 #include <libdaemon/dlog.h>
28 * Returns a banner to go at the bottom of e-mails. Remember to delete it when done.
29 * @return footer string
31 std::string
* smtp_get_banner()
34 * " (o_ Powered by: inoclam v1.0 (Bender)\n"
35 * " //\ Homepage: http://www.inoclam.org/\n"
36 * " V_/_ Author: Vermont Department of Taxes\n"
40 banner
= new std::string();
41 banner
->append(" (o_ Powered by inoclam v");
43 std::string
* version
;
44 version
= new std::string(VERSION
);
45 banner
->append(version
->c_str());
50 std::string
* codename
;
51 codename
= new std::string(CODENAME
);
52 banner
->append(codename
->c_str());
55 banner
->append(")\n");
57 banner
->append(" //\\ Developed by the Vermont Department of Taxes\n");
58 banner
->append(" V_/_ Project Homepage: http://www.inoclam.org/\n");
64 * Returns an RFC 2822 Compliant Date String
67 std::string
* smtp_get_timestamp()
76 timestamp
= (char *) malloc(sizeof(char) * 41);
78 daemon_log(LOG_ERR
, "malloc() failed!");
82 memset(timestamp
, '\0', 41); /* RFC 2822 Date */
83 strftime(timestamp
, 40, "%a, %d %b %Y %H:%M:%S", tm
);
86 tstamp
= new std::string(timestamp
);
99 void smtp_send(char *subject
, std::string
* body
, config
* conf
)
101 char *smtp_host
= conf
->getHost();
102 int smtp_port
= conf
->getPort();
103 char *smtp_from
= conf
->getFrom();
104 const char *smtp_body
= body
->c_str();
106 if (smtp_host
== NULL
|| smtp_from
== NULL
|| smtp_port
< 1 || smtp_port
> 65535 || subject
== NULL
|| smtp_body
== NULL
) {
107 daemon_log(LOG_INFO
, "Incomplete Configuration or Message -- Not Sending E-Mail");
111 for (std::list
< char *>::iterator itr
= conf
->getTo()->begin(); itr
!= conf
->getTo()->end(); ++itr
) {
115 daemon_log(LOG_INFO
, "Mailing '%s' ", smtp_to
);
117 /* Why are there no C libraries for sending mail that are this simple? */
118 jwsmtp::mailer
* mail
;
119 mail
= new jwsmtp::mailer(smtp_to
, smtp_from
, subject
, smtp_body
, smtp_host
, smtp_port
, false);