Ruby Mail gem,如何编写邮件消息脚本
发布时间:2020-12-17 01:21:47 所属栏目:百科 来源:网络整理
导读:我在具有SE Linux许可和IPtables关闭的CENTOS 5 VM上安装了testmail.rb: require 'rubygems'require 'mail'options = { :address = "mail.domain.com",:port = 466,:domain = 'otherdomain.com',:user_name = 'somedude@domain.com',:password = 'topsecret
我在具有SE
Linux许可和IPtables关闭的CENTOS 5 VM上安装了testmail.rb:
require 'rubygems' require 'mail' options = { :address => "mail.domain.com",:port => 466,:domain => 'otherdomain.com',:user_name => 'somedude@domain.com',:password => 'topsecret',:authentication => 'plain',:enable_starttls_auto => true } Mail.defaults do delivery_method :smtp,options end mail = Mail.new do from 'somedude@otherdomain.com' to 'admin@domain.com' subject 'This is a test email' body File.read('body.txt') end puts mail.to_s 运行脚本时的结果如下: Date: Tue,30 Nov 2010 12:12:58 -0500 From: somedude@otherdomain.com To: admin@domain.com Message-ID: <4cf5309a2f074_284015c5c4de91b8270b2@apvdbs03.3rdomain.local.mail> Subject: This is a test email Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit test! “测试!”是body.txt的内容. 没有电子邮件到达发送到帐户.我们从发送到域管理员获得的smtp设置.我使用telnet成功地在未加密的端口(25)上向域发送电子邮件但是没有得到加密端口(466)的响应,可能是因为我的telnet会话未加密? 有什么方法可以看到脚本执行过程中发生的故障排除? 更新: 解决方法
你错过了实际发送的行.尝试添加
mail.deliver! 到你的脚本结束. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- ruby-on-rails – 安装调试器(1.6.8)时发生错误,Bundler无法
- ruby-on-rails – sudo gem install rails-这不会给我bash的
- C# 利用Aspose.Words.dll将 Word 转成PDF
- swift dataStruct
- ruby-on-rails – 专业有用且安全的文件类型列表?
- 如何在C#中使用带有类型化数据集的事务?
- ruby – 如何将用户中断添加到无限循环?
- Oracle RAC SCN传播方式(Broadcast-On-Commit)
- SQLLite (三):sqlite3_get_table,sqlite3_free_table
- 编程的精进之法