Ruby Mail gem,如何编写邮件消息脚本

Ruby Mail gem,如何编写邮件消息脚本,第1张

概述我在具有SE Linux许可和IPtables关闭的CENTOS 5 VM上安装了testmail.rb: require 'rubygems'require 'mail'options = { :address => "mail.domain.com", :port => 466, : 我在具有SE Linux许可和IPtables关闭的CENTOS 5 VM上安装了testmail.rb:

require 'rubygems'require 'mail'options = { :address              => "mail.domain.com",:port                 => 466,:domain               => 'otherdomain.com',:user_name            => '[email protected]',:password             => 'topsecret',:authentication       => 'plain',:enable_starttls_auto => true  } Mail.defaults do  delivery_method :smtp,optionsend mail = Mail.new do      from '[email protected]'        to '[email protected]'   subject 'This is a test email'      body file.read('body.txt') endputs mail.to_s

运行脚本时的结果如下:

Date: Tue,30 Nov 2010 12:12:58 -0500From: [email protected]: [email protected]: <[email protected]>Subject: This is a test emailMime-Version: 1.0Content-Type: text/plain; charset=UTF-8Content-transfer-encoding: 7bittest!

“测试!”是body.txt的内容.

没有电子邮件到达发送到帐户.我们从发送到域管理员获得的smtp设置.我使用telnet成功地在未加密的端口(25)上向域发送电子邮件但是没有得到加密端口(466)的响应,可能是因为我的telnet会话未加密?

有什么方法可以看到脚本执行过程中发生的故障排除?

更新:
尝试重定向:> log.log 2>& 1,但没有提供任何其他信息.

解决方法 你错过了实际发送的行.尝试添加

mail.deliver!

到你的脚本结束.

总结

以上是内存溢出为你收集整理的Ruby Mail gem,如何编写邮件消息脚本全部内容,希望文章能够帮你解决Ruby Mail gem,如何编写邮件消息脚本所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1209693.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-04
下一篇 2022-06-04

发表评论

登录后才能评论

评论列表(0条)

保存