#!/bin/bash boundary="esrf3002j34534534q" from="absender@foo.com" to="empfaenger@example.org" subject="Irgendein Betreff" body="Der Inhalt dieser E-Mail" declare -a anhaenge attachments=( "datei1.tiff" "datei2.tiff" ) { printf '%s\n' "From: $from To: $to Subject: $subject Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=\"$boundary\" --${boundary} Content-Type: text/plain; charset=\"UTF-8\" Content-Transfer-Encoding: 7bit Content-Disposition: inline $body " for file in "${attachments[@]}"; do [ ! -f "$file" ] && echo "Warning: attachment $file not found, skipping" >&2 && continue mimetype=$(get_mimetype "$file") printf '%s\n' "--${boundary} Content-Type: $mimetype Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename=\"$file\" " base64 "$file" echo done printf '%s\n' "--${boundary}--" } | sendmail -t -oi
0 people found this article useful
0 people found this article useful