从 Ubuntu 终端发送邮件时缺少邮件正文:
echo "Test smtp" | sudo ssmtp -vvv [email protected]
邮件已收到,但正文为空。当我尝试手动使用命令时
sudo ssmtp -vvv [email protected]
输入消息后按下CTRL+ ,它就可以正常工作。D
当我尝试使用此命令时,收到主题:
echo "Subject:Test smtp" | sudo ssmtp -vvv [email protected]
但显示此错误信息:
[<-] 554 5.2.0 STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; Failed to process message due to a permanent exception with message Cannot submit message. 0.35250:0A000B81, 1.36674:0A000000, 1.61250:00000000, 1.45378:02000000, 1.44866:601A0000, 1.36674:0E000000, 1.61250:00000000, 1.45378:651A0000, 1.44866:30020000, 16.55847:1F0D0000, 17.43559:0000000004020000000000000000000000000000, 20.52176:140F17891900101043050000, 20.50032:140F17898917000000000000, 0.35180:48050000, 255.23226:0A001081, 255.27962:0A000000, 255.27962:0E000000, 255.31418:0A001181, 0.35250:0A000000, 1.36674:32000000, 1.61250:00000000, 1.45378:02000000, 1.44866:01000000, 16.55847:69000000, 17.43559:00000000F8020000000000000100000000000000, 20.52176:140F17891900101061050000, 20.50032:140F17898917000003000136, 0.35180:66050000, 255.23226:0A001681, 255.27962:32000000, 255.17082:DC040000, 0.27745:0A001781, 4.21921:DC040000, 255.27962:FA000000, 255.1494:0A001881, 0.38698:0F010480, 0.37692:01000000, 0.37948:A7DAB260, 5.33852:00000000534D545000000100, 7.36354:0100000000000109302E3233, 4.56248:DC040000, 7.40748:010000000000010B3A363162, 7.57132:00000000000000006431322D, 1.63016:32000000, 4.39640:DC040000, 8.45434:57402EB65F477B48884BDCB058E3C75D1A010480, 5.10786:0000000031352E32302E323332372E3032353A4D4131505230314D42333634313A36316263646635662D623266372D346431322D623031362D32613231636466383233306400101013000100, 7.51330:EBD4562F8F4CD70800000000, 255.1750:0A002181, 255.31418:03001736, 0.22753:A7050000, 255.21817:DC040000, 4.60547:DC040000, 0.21966:AC050000, 4.30158:DC040000 [Hostname=MA1PR01MB3641.INDPRD01.PROD.OUTLOOK.COM]
ssmtp: 554 5.2.0 STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; Failed to process message due to a permanent exception with message Cannot submit message. 0.35250:0A000B81, 1.36674:0A000000, 1.61250:00000000, 1.45378:02000000, 1.44866:601A0000, 1.36674:0E000000, 1.61250:00000000, 1.45378:651A0000, 1.44866:30020000, 16.55847:1F0D0000, 17.43559:0000000004020000000000000000000000000000, 20.52176:140F17891900101043050000, 20.50032:140F17898917000000000000, 0.35180:48050000, 255.23226:0A001081, 255.27962:0A000000, 255.27962:0E000000, 255.31418:0A001181, 0.35250:0A000000, 1.36674:32000000, 1.61250:00000000, 1.45378:02000000, 1.44866:01000000, 16.55847:69000000, 17.43559:00000000F8020000000000000100000000000000, 20.52176:140F17891900101061050000, 20.50032:140F17898917000003000136, 0.35180:66050000, 255.23226:0A001681, 255.27962:32000000, 255.17082:DC040000, 0.27745:0A001781, 4.21921:DC040000, 255.27962:FA000000, 255.1494:0A001881, 0.38698:0F010480, 0.37692:01000000, 0.37948:A7DAB260, 5.33852:00000000534D545000000100, 7.36354:0100000000000109302E3233, 4.56248:DC040000, 7.40748:010000000000010B3A363162, 7.57132:00000000000000006431322D, 1.63016:32000000, 4.39640:DC040000, 8.45434:57402EB65F477B48884BDCB058E3C75D1A010480, 5.10786:0000000031352E32302E323332372E3032353A4D4131505230314D42333634313A36316263646635662D623266372D346431322D623031362D32613231636466383233306400101013000100, 7.51330:EBD4562F8F4CD70800000000, 255.1750:0A002181, 255.31418:03001736, 0.22753:A7050000, 255.21817:DC040000, 4.60547:DC040000, 0.21966:AC050000, 4.30158:DC040000 [Hostname=MA1PR01MB3641.INDPRD01.PROD.OUTLOOK.COM]
答案1
您需要在主题后添加两个换行符才能添加邮件正文。您可以尝试使用printf
printf "Subject: Via printf\n\nThis mail body is added via printf" | sudo ssmtp -vvv [email protected]
或echo
使用-e
echo -e "Subject: Via echo\n\nThis mail body is added via echo" | sudo ssmtp -vvv [email protected]
答案2
根据Arch Linux,ssmtp
已不再维护。
也就是说,设置完成后您可以使用:
echo -e "Subject: this is the subject\n\nthis is the body" | mail [email protected]