私は単純なブログ(レール5を使用)を作成しようとしています。私は、actionmailerを使用しようとしていると私はユーザーを登録するdeviseを使用しています。私は最初のユーザーだけでそれを設定しようとしています。アクションメーラは電子メールの送受信をしません5
私のローカルサーバーを見ると、電子メールは送信されているように見えますが受信されません。どんなアドバイスも大歓迎です。
UserNotifierMailer#sample_email: processed outbound mail in 410.4ms
Sent mail to [email protected] (853.2ms)
Date: Wed, 27 Jul 2016 12:05:33 +0100
From: [email protected]
To:[email protected]
Message-ID: <[email protected]me.mail>
Subject: Sample Email
Mime-Version: 1.0
Content-Type: multipart/alternative;
boundary="--==_mimepart_5798957d951e2_ae813ff962abfe1466312";
charset=UTF-8
Content-Transfer-Encoding: 7bit
マイポスト・コントローラは、次のようになります。
class UserNotifierMailer < ApplicationMailer
default from: "[email protected]"
def sample_email(user)
@user = user
@url = 'http://www.google.com'
mail(to: @user.email, subject: 'Sample Email')
end
end
と私development.rbに、私はこれらの設定を持っている:
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: "gmail.com",
authentication: "plain",
enable_starttls_auto: true,
user_name: "my_gmail_username",
password: "my_gmail_password"
}
def create
@user = User.first
@post = current_user.posts.build(post_params)
if @post.save
flash[:success] = "Your post has been created!"
UserNotifierMailer.sample_email(@user).deliver
redirect_to posts_path
else
flash[:alert] = "Your new post couldn't be created! Please check the form."
render :new
end
end
私のメーラーは、このようになります
に動作しません。 com/settings/security/lesssecureapps – Deep
私はついにそれを働かせました。それはGoogleの2段階認証と関係していました。それがオフになっていることを確認してください! –