简体   繁体   English

在Rails中,如何使用mdaemon邮件服务器通过Action Mailer发送电子邮件?

[英]In rails, How to send emails with action mailer using mdaemon mail server?

I have installed mdaemon mail server in my computer, and register the email user "administrator@tuzhu001.com". 我已经在计算机上安装了mdaemon邮件服务器,并注册了电子邮件用户“ administrator@tuzhu001.com”。 I have also tested it with "worldclient" that it can send emails correctly. 我还使用“ worldclient”对其进行了测试,它可以正确发送电子邮件。 Now I want to send emails with action mailer using this mail server. 现在,我想使用此邮件服务器发送带有动作邮件的电子邮件。 But I cannot send email correctly. 但是我无法正确发送电子邮件。 The sending email method is shown below: 发送电子邮件的方法如下所示:

def register_email(user)

    ActionMailer::Base.smtp_settings = {
        :address  => "127.0.0.1",
        :port => 25, 
        :domain  => "tuzhu001.com",
        :authentication  => :login,
        :user_name  => "administrator@tuzhu001.com",
        :password => "123456",
    }    
    recipients    user["email"]
    from          "administrator@tuzhu001.com"
    subject       "Welcome to Tuzhu"
    body          (:url => user["url"])
    sent_on       Time.now
end

Anyone can help me? 有人可以帮助我吗?

most likely a problem with your MTA (= Mail Transfer Agent) 您的MTA最有可能出现问题(=邮件传输代理)

  • try to disable password authentication for testing purposes 尝试出于测试目的禁用密码身份验证
  • check if your MTA wants just the username (without domain) for authentication 检查您的MTA是否只需要用户名(无域)进行身份验证

in the call to ActionMailer::Base.smtp_settings() or .sendmail_settings() 在对ActionMailer :: Base.smtp_settings()或.sendmail_settings()的调用中

you should set the content_type 您应该设置content_type

content_type 'text/html' or content_type 'text/plain' content_type'text / html'或content_type'text / plain'

the body should be either a string containing the correct content type 正文应为包含正确内容类型的字符串

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM