Fix email config

This commit is contained in:
2023-03-08 20:28:15 +11:00
parent e30f0df5e1
commit 915c87db9b

View File

@@ -10,26 +10,29 @@ module Adamantium
@from = from @from = from
end end
attr_reader :username, :password, :to, :from
def call(name:, content:) def call(name:, content:)
Mail.defaults do Mail.defaults do
delivery_method :smtp, { delivery_method :smtp, {
address: "smtp.fastmail.com", address: "smtp.fastmail.com",
port: 465, port: 465,
user_name: @username,
password: @password,
authentication: "plain", authentication: "plain",
tls: true, tls: true,
openssl_verify_mode: "peer" openssl_verify_mode: "peer"
} }
end end
Mail.delivery_method.settings[:user_name] = username
Mail.delivery_method.settings[:password] = password
mail = Mail.new do mail = Mail.new do
subject name subject name
body content body content
end end
mail[:to] = @to mail[:to] = to
mail[:from] = @username mail[:from] = username
mail.deliver mail.deliver
end end