if [ "$PAM_TYPE" != "close_session" ]; then host="`hostname`" subject="SSH Login: $PAM_USER from $PAM_RHOST on $host" # Message to send, e.g. the current environment variables. message="`env`" # 使用mailx发送邮件 echo "$message" | mailx -r "$sender" -s "$subject" "$recepient" fi