【问题标题】:Automation of email sending process through corporate webmail通过企业网络邮件实现电子邮件发送过程的自动化
【发布时间】:2015-05-22 12:24:33
【问题描述】:

我需要一个脚本,它可以自动从我的公司网络邮件电子邮件 ID 发送特定数据。

到目前为止,我能够从 gmail id 发送自动电子邮件。但我无法为我的 webmail id 配置它。

如果需要任何配置更改或我需要为此设置服务器,请告诉我。(如果可能,还请帮助我如何配置服务器)

这是我正在使用的 Ruby 函数

def send_mail(to_recepient,data,mailSubject,extraBodyText,sender_info)

    options = { :address              => "smtp.gmail.com",
              :port                 => 587,
              :domain               => 'mail.gmail.com',
              :user_name            => sender_info[:senderName],
              :password             => sender_info[:senderPassword],
              :authentication       => 'plain',
              :enable_starttls_auto => true  }



  Mail.defaults do
    delivery_method :smtp, options
  end

  Mail.deliver do
         to "#{to_recepient}"
       from 'mailtest20152@gmail.com'
    subject mailSubject
      body stringData 

      fh=File.open('attachment_file',"w")

      fh.puts data
     add_file :filename => 'attachment_file', :content => data

  end

  File.unlink('attachment_file')
end

【问题讨论】:

  • 我认为这不是编码问题。如果这适用于 gmail,它也应该适用于任何其他为您提供 smtp 服务器的网络邮件。只需在您的网络邮件中查看它的配置。

标签: ruby smtp sendmail webmail


【解决方案1】:

我遇到了类似的问题。您可以像这样为特定的 smtp 服务器配置邮件程序:

options = { :address              => "smtp.yourdomain.com", #address can differ
          :port                 => 25  }

别忘了补充:

config.action_mailer.delivery_method = :smtp

不需要提供密码和用户名,但请记住在您的电子邮件中指定 from 字段(就像您已经做过的那样)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-03-03
    • 1970-01-01
    • 2017-06-16
    • 1970-01-01
    • 2013-01-16
    • 2021-08-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多