Browse Source

get multi-part working - need to check what happens with plaintext

Pi 1 năm trước cách đây
mục cha
commit
cbcdc5e32e
1 tập tin đã thay đổi với 28 bổ sung18 xóa
  1. 28 18
      cropswap-sendmail.sh

+ 28 - 18
cropswap-sendmail.sh

@@ -6,44 +6,54 @@ cleanup (){
 }
 trap cleanup EXIT
 
+cd "${WD}"
+
 DELIVERED=false
 SENDMAIL="/usr/sbin/sendmail"
 if ((DEBUG != 0)); then
 	SENDMAIL="$DEBUGMAIL"
 fi
-
-cat - > "${WD}/original"
+cat - > original
 reformail \
 	-X "Date:" \
 	-X "MIME-Version:" \
-	-X "Content-Type:" \
 	-X "Subject:" \
-< "${WD}/original" > "${WD}/headers"
-subject="$(reformail -c -x "Subject:" < "${WD}/headers")"
+	-X "Content-Type:" \
+< original > headers
+subject="$(reformail -c -x "Subject:" < headers)"
 if [ "${subject/\[${SUBJECT}\]/}" == "${subject}" ]; then
 	subject="[${SUBJECT}] ${subject## }"
 fi
 
-# multipart/mixed isn't displaying all parts
-content_type="$(reformail -c -x 'Content-Type:' < "${WD}/original")"
-#reformime -s1 -e < "${WD}/original" | makemime -c "${content_type}" - > "${WD}/body"
-#echo "NOTICE:======== <<<" | makemime -c "text/plain" - > "${WD}/banner"
-#makemime -m multipart/mixed "${WD}/banner" > "${WD}/new"
-#makemime -j "${WD}/new" "${WD}/body" | cat "${WD}/headers" - > "${WD}/mail.new"
 
-# doesn't work on plain-text messages...
-#reformime -s1 -e < "${WD}/original" > "${WD}/body"
-#makemime -m "${content_type}" "${WD}/body" | cat "${WD}/headers" - > "${WD}/mail.new"
+echo "NOTICE:======== <<<" | makemime \
+	-c "text/plain" -C 'UTF-8' - | reformail \
+	-i 'Content-Disposition: inline;filename=NOTICE.txt' \
+> banner
+
+reformail \
+        -X 'Content-Type:' \
+        -X 'Content-Transfer-Encoding:' \
+< original | reformail \
+        -i 'Content-Transfer-Encoding: 8bit' \
+	-i 'Content-Disposition: inline' \
+> mime-headers
+reformime -s1 -e < original | cat mime-headers - > alternative
+
 
-reformime -s1 -e < "${WD}/original" | cat "${WD}/headers" - | reformail \
+makemime -m 'multipart/related' -C 'UTF-8' alternative > related
+makemime -j related banner > mixed
+makemime -m 'multipart/mixed' -a 'MIME-Version: 1.0' -C 'UTF-8' mixed | cat headers - | reformail \
+	-U "MIME-Version:" \
+	-U "Content-Type:" \
 	-I "Subject: ${subject}" \
 	-I "List-Id: $MAILGROUP" \
 	-I "List-Unsubscribe: <mailto:$MAILGROUP?subject=[UNSUBSCRIBE]>" \
 	-I "List-Subscribe: <mailto:$MAILGROUP?subject=[SUBSCRIBE]>" \
 	-I "List-Post: <mailto:$MAILGROUP>" \
 	-I "List-Unsubscribe-Post: List-Unsubscribe=One-Click" \
-> "${WD}/mail.new"
-mv "${WD}"/mail{.new,}
+> mail.new
+mv mail{.new,}
 
 declare -A SUBSCRIBED
 declare -a actions
@@ -68,7 +78,7 @@ for email in "${!SUBSCRIBED[@]}"; do
 	echo "Forwarding mail: "
 	echo "From: ${FROM} <${MAILGROUP}>"
 	echo "To: ${SUBSCRIBED["$email"]} <${email}>"
-	"$SENDMAIL" -F "${FROM}" -f "${MAILGROUP}" "${SUBSCRIBED["$email"]} <${email}>" < "${WD}/mail"
+	"$SENDMAIL" -F "${FROM}" -f "${MAILGROUP}" "${SUBSCRIBED["$email"]} <${email}>" < mail
 	DELIVERED=true
 done
 if ! $DELIVERED; then