sh 在shell中发送电子邮件
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 在shell中发送电子邮件相关的知识,希望对你有一定的参考价值。
#!/bin/bash
pwd=`pwd`
from="wubin@edanzgroup.com"
to="wubin@edanzgroup.com"
subject="Today's System backbone dev machine"
# util function to get file mime-type
# e.g. get_mimetype file_path
get_mimetype(){
# warning: assumes that the passed file exists
file --mime-type "$1" | sed 's/.*: //'
}
email_content_file="${pwd}/content.txt"
sysbb_machine=`edanz list | grep i-76a8034e | cut -d $'\t' -f 5 | cut -d ':' -f 2 | xargs`
[ -f email_content_file ] && rm ${email_content_file}
# build body contents
cat <<EOF >${email_content_file}
Today's system backbone dev machine:
${sysbb_machine}
Regards,
Bin Wu
EOF
# attachments
#declare -a attachments
#attachments=( "foo.pdf" "bar.jpg" "archive.zip" )
#declare -a attargs
#for att in "${attachments[@]}"; do
# attargs+=( "-a" "$att" )
#done
# sendmail ${email} < ${email_content_file}
# mail -s "$subject" -r "$from" "${attargs[@]}" "$to" <<< "$body"
# mail -s "$subject" -r "$from" -S smtp="smtp://${smtpserver}:${smtpport}" \
# -S smtp-auth=login \
# -S smtp-auth-user="$user" \
# -S smtp-auth-password="$password" \
# -S sendwait \
# "${attargs[@]}" "$to" <<< "$body"
mail -s "$subject" -r "$from" "$to" <<< $(< ${email_content_file})
exit 0
以上是关于sh 在shell中发送电子邮件的主要内容,如果未能解决你的问题,请参考以下文章
检查在 CakePHP 中发送电子邮件是不是成功/失败?
如何在android中发送电子邮件[重复]
如何在 VC++ 中发送电子邮件?
如何在 Android 中发送电子邮件? [复制]
在 CodeIgniter 中发送电子邮件
在 iOS 5 中发送电子邮件时出错