Письмо отправлено, но без вложения - PullRequest
0 голосов
/ 12 октября 2018

Я использую приведенный ниже скрипт оболочки для отправки электронной почты с вложением.этот скрипт запускает файл, но когда он запускается crontab, файл вложения не отправляется вместе с электронной почтой.т.е. письмо отправлено, но без вложений.

Я запускаю этот скрипт в centos 6.9.

#!/bin/bash
DATE=`date -d "yesterday 13:00 " '+%Y-%m-%d'`
from="myemail@mydomain.com"
to="someone@domain.com"

subject="email title"
boundary="ZZ_/afg6432dfgkl.94531q"

body="email body"

declare -a attachments
attachments=( "action_details.txt" )

{   
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=\"US-ASCII\"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

$body
"

printf "

For More details,  Please check the attached file"

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

# print last boundary with closing --
printf '%s\n' "--${boundary}--"

} | /usr/sbin/sendmail -t -oi   
...