Detailed SMTP setup (#6759)
* add detailed SMTP settings setup in mastodon:setup * add localhost SMTP settings setup in mastodon:setup * SMTP settings setup should exit after successful delivery of test mailpull/389/head
parent
f5f165a5eb
commit
051b649628
|
@ -224,6 +224,12 @@ namespace :mastodon do
|
||||||
prompt.say "\n"
|
prompt.say "\n"
|
||||||
|
|
||||||
loop do
|
loop do
|
||||||
|
if prompt.yes?('Do you want to send e-mails from localhost?', default: false)
|
||||||
|
env['SMTP_SERVER'] = 'localhost'
|
||||||
|
env['SMTP_PORT'] = 25
|
||||||
|
env['SMTP_AUTH_METHOD'] = 'none'
|
||||||
|
env['SMTP_OPENSSL_VERIFY_MODE'] = 'none'
|
||||||
|
else
|
||||||
env['SMTP_SERVER'] = prompt.ask('SMTP server:') do |q|
|
env['SMTP_SERVER'] = prompt.ask('SMTP server:') do |q|
|
||||||
q.required true
|
q.required true
|
||||||
q.default 'smtp.mailgun.org'
|
q.default 'smtp.mailgun.org'
|
||||||
|
@ -244,6 +250,19 @@ namespace :mastodon do
|
||||||
q.echo false
|
q.echo false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
env['SMTP_AUTH_METHOD'] = prompt.ask('SMTP authentication:') do |q|
|
||||||
|
q.required
|
||||||
|
q.default 'plain'
|
||||||
|
q.modify :strip
|
||||||
|
end
|
||||||
|
|
||||||
|
env['SMTP_OPENSSL_VERIFY_MODE'] = prompt.ask('SMTP OpenSSL verify mode:') do |q|
|
||||||
|
q.required
|
||||||
|
q.default 'peer'
|
||||||
|
q.modify :strip
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
env['SMTP_FROM_ADDRESS'] = prompt.ask('E-mail address to send e-mails "from":') do |q|
|
env['SMTP_FROM_ADDRESS'] = prompt.ask('E-mail address to send e-mails "from":') do |q|
|
||||||
q.required true
|
q.required true
|
||||||
q.default "Mastodon <notifications@#{env['LOCAL_DOMAIN']}>"
|
q.default "Mastodon <notifications@#{env['LOCAL_DOMAIN']}>"
|
||||||
|
@ -261,7 +280,8 @@ namespace :mastodon do
|
||||||
:user_name => env['SMTP_LOGIN'].presence,
|
:user_name => env['SMTP_LOGIN'].presence,
|
||||||
:password => env['SMTP_PASSWORD'].presence,
|
:password => env['SMTP_PASSWORD'].presence,
|
||||||
:domain => env['LOCAL_DOMAIN'],
|
:domain => env['LOCAL_DOMAIN'],
|
||||||
:authentication => :plain,
|
:authentication => env['SMTP_AUTH_METHOD'] == 'none' ? nil : env['SMTP_AUTH_METHOD'] || :plain,
|
||||||
|
:openssl_verify_mode => env['SMTP_OPENSSL_VERIFY_MODE'],
|
||||||
:enable_starttls_auto => true,
|
:enable_starttls_auto => true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,6 +291,7 @@ namespace :mastodon do
|
||||||
|
|
||||||
mail = ActionMailer::Base.new.mail to: send_to, subject: 'Test', body: 'Mastodon SMTP configuration works!'
|
mail = ActionMailer::Base.new.mail to: send_to, subject: 'Test', body: 'Mastodon SMTP configuration works!'
|
||||||
mail.deliver
|
mail.deliver
|
||||||
|
break
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
prompt.error 'E-mail could not be sent with this configuration, try again.'
|
prompt.error 'E-mail could not be sent with this configuration, try again.'
|
||||||
prompt.error e.message
|
prompt.error e.message
|
||||||
|
|
Loading…
Reference in New Issue