From efc6bb97237a90f6017874346b12cfe9e8b2933d Mon Sep 17 00:00:00 2001 From: Joe Rayhawk Date: Tue, 29 Mar 2011 13:10:43 -0700 Subject: mailcert.sh: switching subshell to heredoc for sendmail --- mailcert.sh | 64 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 31 insertions(+), 33 deletions(-) (limited to 'mailcert.sh') diff --git a/mailcert.sh b/mailcert.sh index 167e571..6bbe890 100755 --- a/mailcert.sh +++ b/mailcert.sh @@ -68,38 +68,36 @@ export BOUNDARY="$(dd if=/dev/urandom bs=16 count=1 status=noxfer 2>/dev/null | export USERCERTNAME=$(basename "$USERCERT") export CACERTNAME=$(basename "$CACERT") -( - echo "To: $USEREMAIL" - echo "From: $E" - echo "Subject: Certificate from $CACN" - echo "User-Agent: cash mailcert.sh" - echo "MIME-Version: 1.0" - echo "Content-Type: multipart/mixed; boundary=\"$BOUNDARY\"" - echo "" - echo "This is a multipart message in MIME format." - echo "" - echo "--$BOUNDARY" - echo "Content-Type: text/plain" - echo "Content-Disposition: inline" - echo "" - echo "You'll want both of these." - echo "" - echo "$USERCERTNAME is your user certificate." - echo "" - echo "$CACERTNAME is the certificate authority certificate." - echo "--$BOUNDARY" - echo "Content-Type: application/x-x509-ca-cert" - echo "Content-Disposition: attachment; filename=\"$USERCERTNAME\"" - echo "" - cat "$CACERT" - echo "" - echo "--$BOUNDARY" - echo "Content-Type: application/x-x509-ca-cert" - echo "Content-Disposition: attachment; filename=\"$CACERTNAME\"" - echo "" - cat "$USERCERT" - echo "" - echo "--$BOUNDARY--" -) | /usr/lib/sendmail -t +/usr/lib/sendmail << EOF +To: $USEREMAIL +From: $E +Subject: Certificate from $CACN +User-Agent: cash mailcert.sh +MIME-Version: 1.0 +Content-Type: multipart/mixed; boundary="$BOUNDARY" + +This is a multipart message in MIME format. + +--$BOUNDARY +Content-Type: text/plain +Content-Disposition: inline + +You'll want both of these. + +$USERCERTNAME is your user certificate. + +$CACERTNAME is the certificate authority certificate. +--$BOUNDARY +Content-Type: application/x-x509-ca-cert +Content-Disposition: attachment; filename="$USERCERTNAME" + +$(cat "$CACERT") +--$BOUNDARY +Content-Type: application/x-x509-ca-cert +Content-Disposition: attachment; filename="$CACERTNAME" + +$(cat "$USERCERT") +--$BOUNDARY-- +EOF echo "Sent!" -- cgit v1.2.3