发送电子邮件的操作邮件程序错误
action mailer error to deliver email
我正在尝试通过 rails 相关代码中的操作邮件程序实现发送邮件..
我的mailers/user_mailer.rb
class UserMailer < ActionMailer::Base
default :from => "debasish@thejaingroup.com"
def registration_confirmation(user)
mail(:to=>user.email, :subject =>"Registered")
end
end
users.controller 是
def create
@user = User.new(user_params)
respond_to do |format|
if @user.save
UserMailer.registration_confirmation(@user).deliver
format.html { redirect_to @user, notice: 'User was successfully created.' }
format.json { render :show, status: :created, location: @user }
else
format.html { render :new }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
end
在这里,您的 initializer\setup_mail.rb 设置将转到 development.rb
config.action_mailer.default_url_options = { host: 'localhost', port: 9292 }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address =>"smtp.thejaingroup.com",
:domain =>"thejaingroup.com",
:port => 587,
:user_name =>"debasish@thejaingroup.com",
:password =>"************"
:authentication =>"plain"
}
我的观点是.. user_registration.text.erb ---是
Hi sir you successfully Completed signed..........!
我在 运行 这个应用程序后收到一条错误消息..
UsersController 中的 SocketError#create
getaddrinfo: 请求的名称有效,但未找到请求类型的数据。
我认为您在此处使用的地址 'smtp.thejaingroup.com' 不是有效电子邮件服务提供商的地址。如果您尝试使用您的 gmail,那么它应该是 'smtp.gmail.com'。
这是正常的 gmail 配置。
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:user_name => ENV['gmail_username'],
:password => ENV['gmail_password'],
:authentication => "plain",
:enable_starttls_auto => true
}
在这种情况下,所有邮件都会发送到您的 gmail。 .如果你不希望这种情况发生,你可以试试 gem letter_opener 开发环境。对于生产环境,您可能必须使用电子邮件提供商,例如 mandrill 或 sendgrid。
我正在尝试通过 rails 相关代码中的操作邮件程序实现发送邮件..
我的mailers/user_mailer.rb
class UserMailer < ActionMailer::Base
default :from => "debasish@thejaingroup.com"
def registration_confirmation(user)
mail(:to=>user.email, :subject =>"Registered")
end
end
users.controller 是
def create
@user = User.new(user_params)
respond_to do |format|
if @user.save
UserMailer.registration_confirmation(@user).deliver
format.html { redirect_to @user, notice: 'User was successfully created.' }
format.json { render :show, status: :created, location: @user }
else
format.html { render :new }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
end
在这里,您的 initializer\setup_mail.rb 设置将转到 development.rb
config.action_mailer.default_url_options = { host: 'localhost', port: 9292 }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address =>"smtp.thejaingroup.com",
:domain =>"thejaingroup.com",
:port => 587,
:user_name =>"debasish@thejaingroup.com",
:password =>"************"
:authentication =>"plain"
}
我的观点是.. user_registration.text.erb ---是
Hi sir you successfully Completed signed..........!
我在 运行 这个应用程序后收到一条错误消息.. UsersController 中的 SocketError#create getaddrinfo: 请求的名称有效,但未找到请求类型的数据。
我认为您在此处使用的地址 'smtp.thejaingroup.com' 不是有效电子邮件服务提供商的地址。如果您尝试使用您的 gmail,那么它应该是 'smtp.gmail.com'。
这是正常的 gmail 配置。
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:user_name => ENV['gmail_username'],
:password => ENV['gmail_password'],
:authentication => "plain",
:enable_starttls_auto => true
}
在这种情况下,所有邮件都会发送到您的 gmail。 .如果你不希望这种情况发生,你可以试试 gem letter_opener 开发环境。对于生产环境,您可能必须使用电子邮件提供商,例如 mandrill 或 sendgrid。