Skip to content

Commit

Permalink
fix(smtp_server): fixes issue with malformed rcpt to
Browse files Browse the repository at this point in the history
closes #1299
closes #1019
  • Loading branch information
adamcooke committed Jul 27, 2021
1 parent 73870d6 commit e0ba05a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/postal/smtp_server/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,17 @@ def rcpt_to(data)
end

rcpt_to = data.gsub(/RCPT TO\s*:\s*/i, '').gsub(/.*</, '').gsub(/>.*/, '').strip

if rcpt_to.blank?
return '501 RCPT TO should not be empty'
end

uname, domain = rcpt_to.split('@', 2)

if domain.blank?
return '501 Invalid RCPT TO'
end

uname, tag = uname.split('+', 2)

if domain == Postal.config.dns.return_path || domain =~ /\A#{Regexp.escape(Postal.config.dns.custom_return_path_prefix)}\./
Expand Down

0 comments on commit e0ba05a

Please sign in to comment.