config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.smtp_settings = {
address: 'smtp.126.com',
port: '25',
domain: '126.com',
user_name: 'example@126.com',
password: 'xxxx',
authentication: "plain",
enable_starttls_auto: true,
openssl_verify_mode: OpenSSL::SSL::VERIFY_NONE
config.action_mailer.perform_deliveries = true
config.action_mailer.smtp_settings = {
address: 'smtp.126.com',
port: '25',
domain: '126.com',
user_name: 'example@126.com',
password: 'xxxx',
authentication: "plain",
enable_starttls_auto: true,
openssl_verify_mode: OpenSSL::SSL::VERIFY_NONE
}
然后 default from 一定与 user_name 一致
class SendMail < ActionMailer::Base
default from: "example@126.com"
# do something
end