1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
# pm-jasrv-multi.rc -- send multipart MIME message, subroutine for FileSrv
#
# File id
#
# Copyright (C) 1997-2010 Jari Aalto
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details at
# <http://www.gnu.org/copyleft/gpl.html>.
#
# Description
#
# This subroutine is part of MPFS file server. Send out FILE as
# multipart MIME message. The message will always be base64
# encoded before sending.
#
# Input
#
# o JA_SRV_MIME_MULTI_SEND, command to feed the composed and message
# which will handle sending it as multipart MIME.
# o JA_SRV_MULTIPART_THRESHOLD is the hunk size for slitting mail.
# o FILE, only filename part. Included in MIME headers.
# o file, absolute path to send
#
# Change Log (none)
# ............................................................ &init ...
id = "pm-jasrv-multi.rc"
dummy = "
========================================================================
$id: init:
"
fld = ""
ok = "no"
to = `$FORMAIL -rtzxTo:` # LOGFILE: To whom we're sending message
# ........................................................ read file ...
# Read file and base64 encode it to BODY. Flag "yes" is everything is ok
:0 fbw
| $CAT $file
dummy = "$NL$id: Base64 encoding... $NL"
:0 fbw
| $MIME_BIN_64_E
:0 a
{
ok = "yes"
}
# ............................................... error while base64 ...
:0
* ok ?? no
{
# Combine this message to previous field. See pm-tips.txt
msg = "-AX-Error: $MIME_BIN_64_E failed. Notify server admin."
nl nl=${fld+"$NL"} fld="$fld${nl}$msg"
# We might as well kill the body, because user
# doesn't want to receive binary (gzip)
:0 fbw
| echo
:0 wc: $JA_SRV_LOG.$LOCKEXT
| $FORMAIL -I From ${fld+"$fld"} | $SENDMAIL; \
echo " [ja-srv; $file; $JA_SRV_FROM;]" \
>> $JA_SRV_LOG;
}
# ................................. base64 succeeded, send multipart ...
:0
* ! ok ?? no
{
dummy = "$NL$NL$id: Sending multipart message:$NL $to$NL $file$NL"
type = "application/octet-stream"
coding = "base64"
comment = "This is MIME multipart. You must assemble every part$NL\
together in sequential order. Then decode, cat BODY| mmencode -u > $FILE$NL"
:0 fhw
| $FORMAIL \
-I From \
-I "Content-Type: $type" \
-I "Content-Transfer-Encoding: $coding" \
-I "Content-Disposition: attachment; filename=\"$FILE\"" \
-I "Content-Description: $comment"
:0 wc
| $JA_SRV_MIME_MULTI_SEND
:0 a hwic:
| echo " [ja-srv; $type $file; $JA_SRV_FROM;]" \
>> $JA_SRV_LOG;
:0 E
{
dummy = "$NL$NL$id: $JA_MSG_ERROR ERROR While calling $JA_SRV_MIME_MULTI_SEND $NL"
:0 hwic:
| echo " [ja-srv; SENDMAIL FAIL $type $file; $JA_SRV_FROM;]" \
>> $JA_SRV_LOG;
}
}
# kill body contents before saving to log
:0 fbwi
| echo
dummy = "$id: end:"
# Enf of pm-jasrv-multi.rc
|