您好我跟着this railcast开发了从我们的网站向我们公司指定的电子邮件发送消息的可能性。
当我写信息并点击发送时,它显示没有错误信息。在日志文件中,我可以看到这一点。当我处于生产模式时它工作得很好。但现在它在某处停留在空中。
我的Rails应用日志文件:
Sent mail to mailer@ecotechno.lv (8ms)
Date: Thu, 13 Feb 2014 05:16:57 -0700
To: mailer@ecotechno.lv
Message-ID: <52fcb7b922872_5a0a37b07c53851@just107.justhost.com.mail>
Subject: Welcome email
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE html>
<html>
<head>
<meta content=3D'text/html; charset=3DUTF-8' http-equiv=3D'Content-Ty=
pe' />
</head>
<body>
=
<h1>Jums nos=C5=ABt=C4=ABta jauna zi=C5=86a no SIA "Ecotechno" m=C4=81=
jaslapas izmantojot kontaktformu</h1>
=
=
<li>S=C5=ABt=C4=ABt=C4=81js: </li>
<li>Temats:</li>
<p>Zi=C5=86as teksts: </p>
=
</body>
</html>
我的联系表单:
<%= form_for(@message) do |f| %>
<label for="author">Name:</label>
<%= text_field_tag 'senders_name', nil, class: 'required input_field' %>
<div class="cleaner h10"></div>
<label for="email">Email:</label>
<%= text_field_tag 'email', nil, class: 'validate-email required input_field' %>
<div class="cleaner h10"></div>
<label for="subject">Subject:</label>
<%= text_field_tag 'title', nil, class: 'input_field' %>
<div class="cleaner h10"></div>
<label for="text">Message:</label>
<%= text_area_tag 'message_text', nil, class: 'required' %>
<div class="cleaner h10"></div>
<%= submit_tag("Send",:id=>"submit",:class=>"submit_btn float_l") %>
<input type="reset" value="Reset" id="reset" name="reset" class="submit_btn float_r" />
<%end%>
我的config / initializers / setup_mail.rb
ActionMailer::Base.smtp_settings = {
:address => "mail.ecotechno.lv",
:port => 26,
:domain => "ecotechno.lv",
:user_name => "mailer@ecotechno.lv",
:password => "mypassw",
:authentication => "plain",
:enable_starttls_auto => true
}
答案 0 :(得分:1)
在config / environments / development.rb中,添加以下代码以使用SMTP。
config.action_mailer.delivery_method = :smtp