Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optional STARTTLS support #494

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion lib/mail_catcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,19 @@ def parse! arguments=ARGV, defaults=@defaults
options[:smtp_port] = port
end

parser.on("--http-ip IP", "Set the ip address of the http server") do |ip|
parser.on("--smtp-starttls", "Enable STARTTLS for the smtp server") do
options[:smtp_starttls] = true
end

parser.on("--smtp-private-key PATH", String, "Set the private key file for the smtp server") do |path|
options[:smtp_private_key_file] = path
end

parser.on("--smtp-cert PATH", String, "Set the certificate of the smtp server") do |path|
options[:smtp_cert_chain_path] = path
end

parser.on("--http-ip IP", String, "Set the ip address of the http server") do |ip|
options[:http_ip] = ip
end

Expand Down Expand Up @@ -180,6 +192,13 @@ def run! options=nil
EventMachine.run do
# Set up an SMTP server to run within EventMachine
rescue_port options[:smtp_port] do
Smtp.parms = {
starttls: options[:smtp_starttls],
starttls_options: {
private_key_file: options[:smtp_private_key_file],
cert_chain_file: options[:smtp_cert_chain_path],
},
}
EventMachine.start_server options[:smtp_ip], options[:smtp_port], Smtp
puts "==> #{smtp_url}"
end
Expand Down