Handle hostnames with upper-case letters
[webmin.git] / vgetty / email.pl
1 #!/usr/local/bin/perl
2 # email.pl
3 # Email a received message in WAV format to some address
4
5 $no_acl_check++;
6 require './vgetty-lib.pl';
7 &foreign_check("mailboxes") || die "Read User Mail module not installed";
8 &foreign_require("mailboxes", "mailboxes-lib.pl");
9
10 # Get the WAV format message and construct the email
11 open(OUT, "rmdtopvf $ARGV[0] 2>/dev/null | pvftowav 2>/dev/null |");
12 while(read(OUT, $buf, 1024)) {
13         $wav .= $buf;
14         }
15 close(OUT);
16 $now = localtime(time());
17 $host = &get_system_hostname();
18 $body = &text('email_body', $now, $host);
19 $mail = { 'headers' => [ [ 'From', &mailboxes::get_from_address() ],
20                          [ 'To', $config{'email_to'} ],
21                          [ 'Subject', $text{'email_subject'} ] ],
22           'attach' => [ { 'headers' => [ [ 'Content-Type', 'text/plain' ] ],
23                           'data' => $body },
24                         { 'headers' => [ [ 'Content-Transfer-Encoding',
25                                          'base64' ],
26                                          [ 'Content-Type',
27                                            'audio/wav; name="voicemail.wav"' ]],
28                           'data' => $wav } ]
29         };
30
31 # Send the email
32 &mailboxes::send_mail($mail);
33