Debian Codegraph @

doc/utils/ftpmail.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>ftpmail: Automated Email Notifications of Uploads</title>
5 </head>
6
7 <body bgcolor=white>
8
9 <hr>
10 <center>
11 <h2><b><code>ftpmail</code>: Automated Email Notifications of Uploads</b></h2>
12 </center>
13 <hr><br>
14
15 <p>
16 The <code>ftpmail</code> program is a Perl script designed to read
17 ProFTPD's <code>TransferLog</code> log entries, watching for uploads, and
18 to send an automatic email notification when uploads occur. To use
19 <code>ftpmail</code>, you configure your <code>proftpd</code> daemon to
20 write its <code>TransferLog</code> to a <a href="http://www.proftpd.org/docs/howto/Logging.html#FIFOs">FIFO</a>; the <code>ftpmail</code> program is a FIFO
21 reading program which then processes those log messages.
22
23 <p>
24 The most current version of <code>ftpmail</code> is distributed with the
25 ProFTPD source code.
26
27 <h2>Author</h2>
28 <p>
29 Please contact TJ Saunders &lt;tj <i>at</i> castaglia.org&gt; with any
30 questions, concerns, or suggestions regarding this program.
31
32 <p>
33 <hr><br>
34 <h2><a name="Usage">Usage</a></h2>
35 First, you have the following Perl modules installed:
36 <ul>
37 <li>Mail::Sendmail
38 <li>Time::HiRes
39 </ul>
40 You can easily determine if your Perl has these modules present, using:
41 <pre>
42 # perl -MMail::Sendmail -e0
43 # perl -MTime::HiRes -e0
44 </pre>
45 If you see an error similar to:
46 <pre>
47 Can't locate Mail/Sendmail.pm in @INC (@INC contains: <i>...</i>)
48 </pre>
49 it means that you do not have that Perl module installed. Go to <a href="http://search.cpan.org">search.cpan.org</a> to download the latest versions of
50 these modules, and install them as per their instructions.
51
52 <p>
53 Next, you need to create the FIFO that <code>ftpmail</code> will read from.
54 See the <code>mkfifo(1)</code> man page for instructions on how to create
55 a FIFO. Note that you <b>must</b> use <code>mkfifo</code> to create a FIFO;
56 using an ordinary file that happens to have a ".fifo" extension will not work
57 for this.
58
59 <p>
60 After that, you need to start <code>ftpmail</code> running, <i>before</i>
61 starting <code>proftpd</code>. For example, you might do:
62 <pre>
63 # ./ftpmail \
64 --fifo=/var/proftpd/log/transfer.fifo \
65 --from='[email protected]' \
66 --recipient='[email protected]' \
67 --smtp-server=mail.domain.com \
68 --attach-file \
69 --log=/var/proftpd/log/transfer.log &amp;
70 </pre>
71 The key is to make <code>ftpmail</code> run in the background, so that it is
72 constantly running. If the <code>ftpmail</code> process dies, then
73 <code>proftpd</code> will not be able to write the <code>TransferLog</code>.
74
75 <p>
76 The next step is to configure your <code>proftpd</code> daemon to write to
77 the FIFO you created. Thus in your <code>proftpd.conf</code>, you would
78 use the same path as given to <code>ftpmail</code>'s <code>--fifo</code>
79 option, <i>e.g.</i>:
80 <pre>
81 TransferLog /var/proftpd/log/transfer.fifo
82 </pre>
83
84 <p>
85 Then start <code>proftpd</code>, log in, upload a file, and see what happens.
86 One user modified their <code>init</code> for <code>proftpd</code> such
87 that the <code>ftpmail</code> program was automatically started before
88 the <code>proftpd</code> daemon was started.
89
90 <p>
91 <b>Options</b><br>
92 The following shows the full list of <code>ftpmail</code> options; this
93 can also be obtained by running:
94 <pre>
95 # ftpmail --help
96
97 usage: ftpmail [--help] [--fifo $path] [--from $addr] [--log $path]
98 [--recipient $addr] [--subject $string] [--smtp-server $addr]
99 [--attach-file] [--ignore-users $regex | --watch-users $regex]
100
101 The purpose of this script is to monitor the TransferLog written by proftpd
102 for uploaded files. Whenever a file is uploaded by a user, an email
103 will be sent to the specified recipients. In the email there will be
104 the timestamp, the name of the user who uploaded the file, the path to
105 the uploaded file, the size of the uploaded file, and the time it took
106 to upload.
107
108 Command-line options:
109
110 --attach-file If used, this will cause a copy of the uploaded file
111 to be included, as an attachment, in the generated
112 email.
113
114 --auth $path Configures the path to a file containing SMTP
115 authentication information.
116
117 The configured file should look like this:
118
119 user = $user
120 password = $password
121
122 --fifo $path Indicates the path to the FIFO to which proftpd is
123 writing its TransferLog. That is, this is the path
124 that you used for the TransferLog directive in your
125 proftpd.conf. This parameter is REQUIRED.
126
127 --from $addr Specifies the email address to use in the From header.
128 This parameter is REQUIRED.
129
130 --help Displays this message.
131
132 --ignore-users $regex Specifies a Perl regular expression. If the
133 uploading user name matches this regular expression,
134 then an email notification is NOT sent; otherwise,
135 an email is sent.
136
137 --log $path Since this script reads the TransferLog using FIFOs,
138 the actual TransferLog file is not written by default.
139 Use this option to write the normal TransferLog file,
140 in addition to watching for uploads.
141
142 --recipient $addr Specifies an email address to which to send an email
143 notification of the upload. This option can be
144 used multiple times to specify multiple recipients.
145 AT LEAST ONE recipient is REQUIRED.
146
147 --smtp-server $addr Specifies the SMTP server to which to send the email.
148 This parameter is REQUIRED.
149
150 --subject $string Specify a custom Subject header for the email sent.
151 The default Subject is:
152
153 User '$user' uploaded file '$file' via FTP
154
155 --watch-users $regex Specifies a Perl regular expression. If the
156 uploading user name matches this regular expression,
157 then an email notification is sent; otherwise,
158 no email is sent.
159 </pre>
160
161 <p><a name="FAQ"></a>
162 <b>FAQ</b><br>
163
164 <p>
165 <font color=red>Question</font>: I would like to use <code>ftpmail</code>
166 to send emails, but only for files uploaded to specific domains. How do
167 I do this?<br>
168 <font color=blue>Answer</font>: To do this, you will need to configure
169 different <code>TransferLog</code> files in your different
170 <code>&lt;VirtualHost&gt;</code> sections in your <code>proftpd.conf</code>.
171
172 <p>
173 The TransferLog file format does not include a field indicating the IP
174 address (or DNS name) of the server on which the file transfer is occurring.
175 This means that <code>ftpmail</code> does not know which server is handling
176 the transfer. So, in order to have <code>ftpmail</code> send emails only
177 for certain domains/servers, you will have to do something like:
178 <pre>
179 &lt;VirtualHost a.b.c.d&gt;
180 ...
181 TransferLog /path/to/vhost1.xferlog
182 ..
183 &lt;/VirtualHost&gt;
184
185 &lt;VirtualHost e.f.g.h&gt;
186 ...
187 TransferLog /path/to/vhost2.xferlog
188 ...
189 &lt;/VirtualHost&gt;
190 </pre>
191 Then start instances of <code>ftpmail</code> running, but only for the
192 <code>TransferLog</code> files of the domains/virtual servers to be monitored.
193
194 <p>
195 <hr>
196 <font size=2><b><i>
197 &copy; Copyright 2008-2012 TJ Saunders<br>
198 All Rights Reserved<br>
199 </i></b></font>
200 <hr>
201
202 </body>
203 </html>