Debian Codegraph @

doc/contrib/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 location 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 $addrs] [--upload-recipient \$addrs]
99 [--download-recipient $addrs] [--subject $string] [--smtp-server $addr]
100 [--attach-file] [--ignore-users $regex | --watch-users $regex]
101
102 The purpose of this script is to monitor the TransferLog written by proftpd
103 for uploaded files. Whenever a file is uploaded by a user, an email
104 will be sent to the specified recipients. In the email there will be
105 the timestamp, the name of the user who uploaded the file, the path to
106 the uploaded file, the size of the uploaded file, and the time it took
107 to upload.
108
109 Command-line options:
110
111 --attach-file If used, this will cause a copy of the uploaded file
112 to be included, as an attachment, in the generated
113 email.
114
115 --auth $path Configures the path to a file containing SMTP
116 authentication information.
117
118 The configured file should look like this:
119
120 user = $user
121 password = $password
122
123 --fifo $path Indicates the path to the FIFO to which proftpd is
124 writing its TransferLog. That is, this is the path
125 that you used for the TransferLog directive in your
126 proftpd.conf. This parameter is REQUIRED.
127
128 --from $addr Specifies the email address to use in the From header.
129 This parameter is REQUIRED.
130
131 --help Displays this message.
132
133 --ignore-users $regex Specifies a Perl regular expression. If the
134 uploading user name matches this regular expression,
135 then an email notification is NOT sent; otherwise,
136 an email is sent.
137
138 --log $path Since this script reads the TransferLog using FIFOs,
139 the actual TransferLog file is not written by default.
140 Use this option to write the normal TransferLog file,
141 in addition to watching for uploads.
142
143 --recipient $addr Specifies an email address to which to send an email
144 notification of the upload. This option can be
145 used multiple times to specify multiple recipients.
146 AT LEAST ONE recipient is REQUIRED.
147
148 --upload-recipient $addr
149 Same as --recipient.
150
151 --download-recipient $addr
152 Specifies an email address to which to send an email
153 notification of the download. This option can be
154 used multiple times to specify multiple recipients.
155
156 If this option is specified, then ftpmail will watch
157 for FTP downloads as well as uploads.
158
159 --smtp-server $addr Specifies the SMTP server to which to send the email.
160 This parameter is REQUIRED.
161
162 --subject $string Specify a custom Subject header for the email sent.
163 The default Subject is:
164
165 User '$user' uploaded file '$file' via FTP
166
167 --watch-users $regex Specifies a Perl regular expression. If the
168 uploading user name matches this regular expression,
169 then an email notification is sent; otherwise,
170 no email is sent.
171 </pre>
172
173 <p><a name="FAQ"></a>
174 <b>FAQ</b><br>
175
176 <p>
177 <font color=red>Question</font>: I would like to use <code>ftpmail</code>
178 to send emails, but only for files uploaded to specific domains. How do
179 I do this?<br>
180 <font color=blue>Answer</font>: To do this, you will need to configure
181 different <code>TransferLog</code> files in your different
182 <code>&lt;VirtualHost&gt;</code> sections in your <code>proftpd.conf</code>.
183
184 <p>
185 The TransferLog file format does not include a field indicating the IP
186 address (or DNS name) of the server on which the file transfer is occurring.
187 This means that <code>ftpmail</code> does not know which server is handling
188 the transfer. So, in order to have <code>ftpmail</code> send emails only
189 for certain domains/servers, you will have to do something like:
190 <pre>
191 &lt;VirtualHost a.b.c.d&gt;
192 ...
193 TransferLog /path/to/vhost1.xferlog
194 ..
195 &lt;/VirtualHost&gt;
196
197 &lt;VirtualHost e.f.g.h&gt;
198 ...
199 TransferLog /path/to/vhost2.xferlog
200 ...
201 &lt;/VirtualHost&gt;
202 </pre>
203 Then start instances of <code>ftpmail</code> running, but only for the
204 <code>TransferLog</code> files of the domains/virtual servers to be monitored.
205
206 <p>
207 <hr>
208 <font size=2><b><i>
209 &copy; Copyright 2008-2017 TJ Saunders<br>
210 All Rights Reserved<br>
211 </i></b></font>
212 <hr>
213
214 </body>
215 </html>