1
0
مراية لـ https://github.com/postalserver/postal.git تم المزامنة 2025-11-30 21:32:30 +00:00

add script for testing app SMTP connections

هذا الالتزام موجود في:
Adam Cooke
2017-04-28 17:09:39 +01:00
الأصل 6fc82b2049
التزام 3333a7baf3
6 ملفات معدلة مع 42 إضافات و2 حذوفات

عرض الملف

@@ -44,4 +44,8 @@ class AppMailer < ApplicationMailer
mail :to => @server.organization.notification_addresses, :subject => "[#{server.full_permalink}] Your mail server has been suspended"
end
def test_message(recipient)
mail :to => recipient, :subject => "Postal SMTP Test Message"
end
end

عرض الملف

@@ -0,0 +1,3 @@
This is a test message sent by Postal.
If you have received this message your test has succeeded.

عرض الملف

@@ -84,6 +84,10 @@ case "$1" in
run "bundle exec ruby script/make_user.rb"
;;
test-app-smtp)
run "bundle exec ruby script/test_app_smtp.rb $2"
;;
bundle)
if [ -n "$2" ]; then
run "bundle install --path=$2 --without=development --jobs=4 --clean"

عرض الملف

@@ -27,7 +27,7 @@ Rails.application.configure do
end
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_caching = false

عرض الملف

@@ -55,7 +55,7 @@ Rails.application.configure do
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
config.action_mailer.raise_delivery_errors = true
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).

29
script/test_app_smtp.rb Executable file
عرض الملف

@@ -0,0 +1,29 @@
#!/usr/bin/env ruby
trap("INT") { puts ; exit }
if ARGV[0].nil? || !(ARGV[0] =~ /@/)
puts "usage: postal test-app-smtp [email address]"
exit 1
end
require_relative '../config/environment'
begin
Timeout.timeout(10) do
AppMailer.test_message(ARGV[0]).deliver
end
puts "\e[32mMessage has been sent successfully.\e[0m"
rescue => e
puts "\e[31mMessage was not delivered successfully to SMTP server.\e[0m"
puts "Error: #{e.class} (#{e.message})"
puts
puts " SMTP Host: #{Postal.config.smtp.host}"
puts " SMTP Port: #{Postal.config.smtp.port}"
puts " SMTP Username: #{Postal.config.smtp.username}"
puts " SMTP Password: #{Postal.config.smtp.password}"
puts
rescue Timeout::Error
puts "Sending timed out"
end