مراية لـ
https://github.com/postalserver/postal.git
تم المزامنة 2025-12-01 05:43:04 +00:00
initial commit from appmail
هذا الالتزام موجود في:
39
script/generate_initial_config.rb
Executable file
39
script/generate_initial_config.rb
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env ruby
|
||||
require File.expand_path('../../lib/postal/config', __FILE__)
|
||||
require 'openssl'
|
||||
|
||||
unless File.exist?(Postal.config_file_path)
|
||||
FileUtils.cp(config_root('postal.example.yml'), Postal.config_file_path)
|
||||
puts "Created example config file at #{Postal.config_file_path}"
|
||||
end
|
||||
|
||||
unless File.exists?(Postal.smtp_private_key_path)
|
||||
key = OpenSSL::PKey::RSA.new(2048).to_s
|
||||
File.open(Postal.smtp_private_key_path, 'w') { |f| f.write(key) }
|
||||
puts "Created new private key for encrypting SMTP connections"
|
||||
end
|
||||
|
||||
unless File.exist?(Postal.smtp_certificate_path)
|
||||
cert = OpenSSL::X509::Certificate.new
|
||||
cert.subject = cert.issuer = OpenSSL::X509::Name.parse("/C=GB/O=Test/OU=Test/CN=Test")
|
||||
cert.not_before = Time.now
|
||||
cert.not_after = Time.now + 365 * 24 * 60 * 60
|
||||
cert.public_key = Postal.smtp_private_key.public_key
|
||||
cert.serial = 0x0
|
||||
cert.version = 2
|
||||
cert.sign Postal.smtp_private_key, OpenSSL::Digest::SHA256.new
|
||||
File.open(Postal.smtp_certificate_path, 'w') { |f| f.write(cert.to_pem) }
|
||||
puts "Created new self signed certificate for encrypting SMTP connections"
|
||||
end
|
||||
|
||||
unless File.exists?(Postal.lets_encrypt_private_key_path)
|
||||
key = OpenSSL::PKey::RSA.new(2048).to_s
|
||||
File.open(Postal.lets_encrypt_private_key_path, 'w') { |f| f.write(key) }
|
||||
puts "Created new private key for Let's Encrypt"
|
||||
end
|
||||
|
||||
unless File.exists?(Postal.signing_key_path)
|
||||
key = OpenSSL::PKey::RSA.new(2048).to_s
|
||||
File.open(Postal.signing_key_path, 'w') { |f| f.write(key) }
|
||||
puts "Created new signing key for DKIM & HTTP requests"
|
||||
end
|
||||
35
script/insert-bounce.rb
Executable file
35
script/insert-bounce.rb
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# This script will insert a message into your database that looks like a bounce
|
||||
# for a message that you specify.
|
||||
|
||||
# usage: insert-bounce.rb [serverid] [messageid]
|
||||
|
||||
if ARGV[0].nil? || ARGV[1].nil?
|
||||
puts "usage: #{__FILE__} [server-id] [message-id]"
|
||||
exit 1
|
||||
end
|
||||
|
||||
require_relative '../config/environment'
|
||||
|
||||
server = Server.find(ARGV[0])
|
||||
puts "Got server #{server.name}"
|
||||
|
||||
template = File.read(Rails.root.join('resource/postfix-bounce.msg'))
|
||||
|
||||
if ARGV[1].to_s =~ /\A(\d+)\z/
|
||||
message = server.message_db.message(ARGV[1].to_i)
|
||||
puts "Got message #{message.id} with token #{message.token}"
|
||||
template.gsub!('{{MSGID}}', message.token)
|
||||
else
|
||||
template.gsub!('{{MSGID}}', ARGV[1].to_s)
|
||||
end
|
||||
|
||||
message = server.message_db.new_message
|
||||
message.scope = 'incoming'
|
||||
message.rcpt_to = "#{server.token}@#{Postal.config.dns.return_path}"
|
||||
message.mail_from = "MAILER-DAEMON@smtp.infra.atech.io"
|
||||
message.raw_message = template
|
||||
message.bounce = 1
|
||||
message.save
|
||||
puts "Added message with id #{message.id}"
|
||||
المرجع في مشكلة جديدة
حظر مستخدم