我希望通过 mailx 从我的 C 代码中向收件人列表发送消息。
我想向 /home/me/Email_List.txt 文件中的每个人发送一封包含“message”变量内容的电子邮件。
if(send_email)
{
char* message = "Testing email";
//send contents of 'message' to everyone in /home/me/Email_List.txt
}
我需要 C 程序和 mailx 命令的帮助。这是我的 mailx 命令,它不太工作:
//This works, but I don't want to send the contents of Email_List.txt
cat /home/me/Email_List.txt /home/me/Email_List.txt | mailx -t -s "Test"
//This doesn't work, error:
//cat: cannot open Test Text
cat /home/me/Email_List.txt "Test Text" | mailx -t -s "Test"
我可以在发送之前将文本写入文件,但这似乎效率低下。
想法?