从 C/C++ 发送电子邮件Linux 中的程序
我想在每次模拟结束时向我的 Gmail 帐户发送一封电子邮件。我尝试在网上搜索并发现 sendEmail 但超时。如果有人能向我指出他们尝试过的包或链接,我将不胜感激。
谢谢
I would like to send an email to my gmail account everytime my simulation ends. I have tried searching the web and found sendEmail but it is timing-out. If anyone could point me out to a package or link that they tried I would be thankful.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可以使用
popen()
直接调用本地 MTA 并向其提供符合 RFC822 的文本。You could invoke your local MTA directly using
popen()
and feed it RFC822-compliant text.libESMTP 似乎就是您正在寻找的东西。它有很好的文档记录,并且似乎正在积极开发中(最后一个候选版本是 2012 年 1 月中旬)。它还支持 SSL 和各种身份验证协议。
源码包中有示例应用程序。
libESMTP seems to be what you are looking for. It's very well documented and also seems to be under active development (last Release Candidate is from mid-January 2012). It also supports SSL and various authentication protocols.
There are example applications in the source package.
VMime 和 libcurl 是用于电子邮件发送(以及更多)的优秀库。
Both VMime and libcurl are good libraries for email sending (and more).
我喜欢上面 trojanfoe 的答案,但就我而言,我需要打开电子邮件发送代理.. MTA 来使 linux 能够发送电子邮件 - 我发现 exim4 是一个相对简单的 MTA 来工作,并且 trojanfoe 的程序可以工作非常好用。
为了让它工作,我使用了(在虚拟机中的 debian 类型系统上(crunchbang linux))
我配置了 exim4
我告诉计算机我的正常(远程)电子邮件地址
希望这可能有用,因为我发现这些步骤可以让我的 Linux 系统使用上面的 trojanfoe 电子邮件程序发送电子邮件
I like the answer of trojanfoe above, BUT in my case I needed to turn on an email sending agent.. an MTA to enable linux to send emails - I have found exim4 to be a relatively simple MTA to get working and that trojanfoe's program works very nicely with it.
to get it to work I used (on a debian type system in a virtual box (crunchbang linux))
I configured exim4 with
and I told the computer about my normal (remote) email address with
hope this might be useful as these were the steps I found worked to get my linux system sending email with trojanfoe's email program above
执行 fork exec 并将主体通过管道传输到 sendmail/mail 等程序:
Do a fork exec and pipe the body to a program like sendmail/mail: