Sabo
11/07/2022, 11:32 AMRAILS_ENV=production rails db:setup
, for the admin user I entered something like 'user@mywebdomain.net' for the Email/login but I got :
rails aborted!
Net::SMTPFatalError: <store@example.com>: Sender address rejected: Domain <http://example.com|example.com> does not accept mail (nullMX)
/home/computer/shop/db/seeds.rb:10:in `main`
PS. I'm using solidus_core 3.2.2 && solidus_auth_devise 2.5.4waiting_for_dev
11/07/2022, 11:48 AMSabo
11/07/2022, 12:41 PMconfig/application.rb
? because I did in config/environments/production.rb
waiting_for_dev
11/07/2022, 12:51 PMwaiting_for_dev
11/07/2022, 12:51 PMSabo
11/07/2022, 1:28 PMRails.application.configure do
...
# SMTP Config
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.perform_caching = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.smtp_settings = {
address: '<http://mail.gandi.net|mail.gandi.net>',
port: 465,
domain: '<http://gandi.net|gandi.net>',
user_name: Rails.application.credentials.mail[:username],
password: Rails.application.credentials.mail[:password],
authentication: 'plain',
ssl: true,
tsl: true,
enable_starttls_auto: true
}
...
end
Sabo
11/07/2022, 1:36 PMwaiting_for_dev
11/07/2022, 2:22 PMwaiting_for_dev
11/07/2022, 2:22 PM/home/computer/shop/db/seeds.rb:10
?Sabo
11/07/2022, 4:34 PMSpree::Auth::Engine.load_seed if defined?(Spree::Auth)
in full :
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }])
# Character.create(name: "Luke", movie: movies.first)
Spree::Core::Engine.load_seed if defined?(Spree::Core)
Spree::Auth::Engine.load_seed if defined?(Spree::Auth)
waiting_for_dev
11/08/2022, 2:41 PMsolidus_auth_devise
seeds don’t seem like being messing with email configuration: https://github.com/solidusio/solidus_auth_devise/blob/master/db/default/users.rbwaiting_for_dev
11/08/2022, 2:42 PMwaiting_for_dev
11/08/2022, 2:45 PM<http://gandi.net|gandi.net>
?Sabo
11/08/2022, 2:55 PM<http://gandi.net|gandi.net>
$ RAILS_ENV=production rails c
Loading production environment (Rails 7.0.4)
irb(main):001:0> Rails.application.config.action_mailer.smtp_settings[:domain]
=> "<http://gandi.net|gandi.net>"
Sabo
11/08/2022, 3:38 PMinitializers/spree.rb
I have something like this config.mails_from = "<mailto:user@mywebdomain.net|user@mywebdomain.net>"
waiting_for_dev
11/09/2022, 5:39 AMdb:setup
you’re trying to load all the sample data usually consumed only in development. That includes a sample store setting <mailto:store@example.com|store@example.com>
as the Store#mail_from_address
. However, you’re already configuring the mail server for production. You have two options:
• If you don’t want the sample data in production, instead of db:setup
run:
◦ bin/rails db:create
◦ bin/rails db:schema:load
◦ `bin/rails spree_authadmincreate`to create an admin user
• If you do want the sample data in production, you need to create a sample store with a #mail_from_address
that will work in your case. E.g., from the console (bin/rails console
):
◦ Spree::Store.create(code: 'sample-store', name: 'Sample Store', url: '<http://sample_url.com>', mail_from_address: '<mailto:real_address@gandi.net|real_address@gandi.net>')
It’s essential that the code is sample-store
(so that Solidus skips creating it) and that mail_from_address
is your actual email address.
◦ After that, you should be able to run bin/rails db:setup
.Sabo
11/09/2022, 7:34 AMSabo
11/09/2022, 9:38 AMrails aborted!
ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true
/home/computer/shop/app/mailers/spree/user_mailer.rb:14:in `confirmation_instructions'
I added config.action_mailer.default_url_options = { :host => "mywebdomain" }
in environments/production.rb
but I still got the same errorwaiting_for_dev
11/09/2022, 11:52 AMRails.application.routes.default_url_options[:host] = "<http://mywebdomain.com|mywebdomain.com>"
Sabo
11/09/2022, 2:24 PMRails.application.routes.default_url_options[:host] = "<http://mywebdomain.com|mywebdomain.com>"
in environments/production.rb
it's still the same error.
Maybe I should create a store before run rails spree_auth:admin:create
?waiting_for_dev
11/09/2022, 3:40 PM/home/computer/shop/app/mailers/spree/user_mailer.rb:14
. I think I know what it contains, but only to confirm.Sabo
11/09/2022, 3:58 PM@confirmation_url = spree.spree_user_confirmation_url(confirmation_token: token, host: @store.url)
in full:
# frozen_string_literal: true
module Spree
class UserMailer < BaseMailer
def reset_password_instructions(user, token, *_args)
@store = Spree::Store.default
@edit_password_reset_url = spree.edit_spree_user_password_url(reset_password_token: token, host: @store.url)
mail to: user.email, from: from_address(@store), subject: "#{@store.name} #{I18n.t(:subject, scope: [:devise, :mailer, :reset_password_instructions])}"
end
def confirmation_instructions(user, token, _opts = {})
@store = Spree::Store.default
@email = user.email
@confirmation_url = spree.spree_user_confirmation_url(confirmation_token: token, host: @store.url)
mail to: @email, from: from_address(@store), subject: "#{@store.name} #{I18n.t(:subject, scope: [:devise, :mailer, :confirmation_instructions])}"
end
end
end
waiting_for_dev
11/10/2022, 5:04 AM@store.url
part, as it’s probably resolving to nil
. You need to create a store up front and assign a URL to it.waiting_for_dev
11/10/2022, 6:44 AMSabo
11/10/2022, 8:05 AM