mirror of
https://github.com/postalserver/postal.git
synced 2026-10-20 11:17:01 +00:00
Add IP-based SMTP authentication (#1149)
This commit is contained in:
@@ -312,8 +312,18 @@ module Postal
|
||||
end
|
||||
|
||||
else
|
||||
# This is unaccepted mail
|
||||
'530 Authentication required'
|
||||
# User is trying to relay but is not authenticated. Try to authenticate by IP address
|
||||
@credential = Credential.where(:type => 'SMTP-IP').all.sort_by { |c| c.ipaddr&.prefix || 0 }.reverse.find do |credential|
|
||||
credential.ipaddr.include?(@ip_address)
|
||||
end
|
||||
|
||||
if @credential
|
||||
# Retry with credential
|
||||
@credential.use
|
||||
rcpt_to(data)
|
||||
else
|
||||
'530 Authentication required'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user