Tag: actionmailer

Ruby:Mail gem在邮件中添加60个字符后添加\ r \ n

我想将actionmailer_x509移植到Rails 3.为了做到这一点,我尝试使用签名电子邮件从大字符串创建Mail对象。 你可以在这一行看到这样的创作: https : //github.com/petRUShka/actionmailer_x509/blob/master/lib/actionmailer_x509.rb#L129 原始字符串( smime0 ): https : //gist.github.com/1d2c84cc2e255be010a6 已解决的邮件对象转储到文件( newm ): https : //gist.github.com/4682fe88e8dcfeca60b2 例如,您可以看到smime0的第26行与newm的第40行之间的差异。 在smime0 \r\n中,在每个64个字符之后设置,并且在每个60个字符之后设置newm \r\n 。 这种行为破坏了签名。 是否有可能改变这种行为? 我试图找出如何关闭它,但失败了。 对于这一点,可能还有其他一些解决方法。 PS Mail gem: https : //github.com/mikel/mail ,讨论x509和actionmailer的线程: 如何从Rails 3中的ActionMailer发送签名的电子邮件?

通过Gmail发送电子邮件,但配置不同的电子邮件地址

我正在尝试使用GMail的smtp服务器从我的rails应用程序发送电子邮件。 我发送的电子邮件看起来像是从我自己的Gmail地址发送的,而我希望它们来自info@myapp.com。 我使用三种方式身份validation配置了这个东西,我的应用程序有它唯一的密码。 这是我的production.rb config.action_mailer.default_url_options = { host: ‘my ip’, protocol: ‘https’ } config.action_mailer.delivery_method = :smtp config.action_mailer.asset_host = “https://my ip” 这是我的initializers/smtp.rb MyApp::Application.configure do config.action_mailer.smtp_settings = { enable_starttls_auto: “true”, address: “smtp.gmail.com”, port: “587”, domain: “mydomain.com”, authentication: :plain, user_name: ‘myusername@gmail.com’, password: ‘mypassword’ } end 可能吗? 我怎么能这样做?

在Action Mailer中设置实例变量?

我想知道在Mailers中设置实例变量的干净和传统方法是什么? 目前,我已经在Mailer重新定义了initialize方法,并且随后在从Mailerinheritance的任何邮件程序中需要时覆盖某些实例变量。 class Mailer < ActionMailer::Base attr_reader :ivar def initialize super @ivar = :blah … end end 这对我来说似乎很奇怪,因为new是邮件的私有方法。 例如,如果我尝试在rails控制台中检索这些,我需要执行以下操作: mailer = Mailer.send(:new) mailer.ivar 我也考虑过将它们添加到default哈希中,如下所示: class Mailer < ActionMailer::Base default ivar: :blah, … end 唯一的问题是我需要创建一个这样的方法来检索ivars: def default_getter(ivar) self.class.default[ivar] end 这两种方式对我来说都不是特别干净。 我考虑过使用类变量,但我想知道是否有人可以提出更清洁的方法。 谢谢。

Actionmailer – Sparkpost模板和多语言

这是我第一次在rails项目中设置邮件。 我被告知要使用SparkPost并为多个操作创建不同语言的模板。 为简单起见,我们说一个user_signed_up(用户)邮件。 目前我有这个设置工作: gem安装:’sparkpost’ mail.rb ActionMailer::Base.smtp_settings = { address: “smtp.sparkpostmail.com”, port: 587, enable_starttls_auto: true, user_name: “SMTP_Injection”, password: SPARKPOST_API_KEY, domain: ‘foo-bar.com’ } ActionMailer::Base.delivery_method = :smtp ActionMailer::Base.default charset: “utf-8″ application_mailer.rb require ‘sparkpost’ class ApplicationMailer < ActionMailer::Base default from: "Seal Notification ” layout ‘mailer’ end signup_mailer.rb class SignupMailer < ApplicationMailer def user_signed_up(user) receiver = user.email sender = […]

对于将使用邮件程序参数的ActionMailer的Rails before_action

假设我有一个邮件发送不同的电子邮件,但预计将使用相同的参数调用。 我想为所有邮件程序操作处理这些参数。 因此,调用before_action将读取发送到邮件程序方法的参数 /mailers/my_mailer.rb class MyMailer < ApplicationMailer before_filter do |c| # c.prepare_mail # Will fail, because I need to pass `same_param` arguments # # I want to send the original arguments # c.prepare_mail(same_param) # How do I get `same_param` here ? end def action1(same_param) # email view is going to use @to, @from, @context […]

如何从ActionMailer发送已签名的电子邮件?

我使用GMail作为我的SMTP服务器。 我的配置工作得很好: # config/initializers/action_mailer.rb: ActionMailer::Base.smtp_settings = { :tls => true, :address => “smtp.gmail.com”, :port => “587”, :domain => “www.example.org”, :authentication => :login, :user_name => “admin@example.org”, :password => “it’s a secret” } 我在config/ssl/rsa.public和config/ssl/rsa.private也有一个公共/私有RSA密钥对。 在将电子邮件发送到GMail的SMTP服务器之前,我该如何签名?

如何从Rails 3中的ActionMailer发送已签名的电子邮件?

使用Rails 3我想使用X.509证书来签署部分电子邮件。 Rails 2目前存在答案, 如何从ActionMailer发送签名的电子邮件? 但它不适用于Rails 3。 是否可以通过Rails 3中的ActionMailer签署电子邮件? 如果无法做到这一点,是否可以在ActionMailer创建后通过sendmail签署电子邮件?

Ruby on Rails-Action邮件没有按照要求?

我有2个模型po和send po:has_many发送 发送:belongs_to po send po send_controller class SendsController < ApplicationController def new @send = Send.new end def create @send = Send.new(params[:send]) if @send.save Pomailer.registration_confirmation(@send).deliver flash[:success] = "Send mail" redirect_to capax_path else flash[:warning] = "mail not send" redirect_to capax_path end end pomailer class Pomailer “xyz@yahoo.co.in”, :subject => ” New purchase order send by ” ) […]

如何在rake任务中包含ActionMailer类?

我想在我的rake任务中使用ActionMailer,以便在特定时间向人们发送电子邮件。 我在app / mailers文件夹中编写了一个mailer类,如下所示: class AlertsMailer < ActionMailer::Base default from: 'x@y.com' def mail_alert(email_addresses, subject, url) @url = '#{url}' mail(to: email_addresses, subject: 'Alert') do |format| format.html { render '/alerts/list' } end end end 然后我在rake任务中包含以下行: AlertsMailer.mail_alert(email_addresses, subject) 当我尝试运行rake任务时: rake update_db 我收到以下错误: uninitialized constant AlertsMailer 我想我必须以某种方式在我的rake任务中加载邮件程序类,但我不知道该怎么做。 请帮忙。

Actionmailer不使用rails 3传递邮件

我正在尝试创建一个应用程序,在用户注册时发送电子邮件。 我在config / application.rb文件中输入了gmail的smtp设置,邮件function看起来像 mail(:to => “me@me.com”, :subject => “Mail!”, :from => “another@me.com”, :content_type => “text/html”) 现在,当我看到日志时,我看到它说邮件已被发送,但我从未收到任何邮件… 另外,当我调用邮件传递函数Emails.signed(@user).deliver ,表单页面不会重定向,但如果我注释掉发送代码的电子邮件,它就可以工作 Emails.signed(@user).deliver 要么 mail(:to => “me@me.com”, :subject => “Mail!”, :from => “another@me.com”, :content_type => “text/html”) 谢谢 :) 编辑:development.rb App::Application.configure do # Settings specified here will take precedence over those in config/environment.rb # In the development environment your […]