Skip to content

Commit

Permalink
issue #198 - remove helo/ehlo from the population on headers
Browse files Browse the repository at this point in the history
  • Loading branch information
flashmob committed Dec 3, 2019
1 parent 0258f19 commit a32e269
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
12 changes: 10 additions & 2 deletions backends/p_guerrilla_db_redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,11 +435,19 @@ func GuerrillaDbRedis() Decorator {
e.Subject,
ts)
e.QueuedId = hash

// Add extra headers
protocol := "SMTP"
if e.ESMTP {
protocol = "E" + protocol
}
if e.TLS {
protocol = protocol + "S"
}
var addHead string
addHead += "Delivered-To: " + to + "\r\n"
addHead += "Received: from " + e.Helo + " (" + e.Helo + " [" + e.RemoteIP + "])\r\n"
addHead += " by " + e.RcptTo[0].Host + " with SMTP id " + hash + "@" + e.RcptTo[0].Host + ";\r\n"
addHead += "Received: from " + e.RemoteIP + " ([" + e.RemoteIP + "])\r\n"
addHead += " by " + e.RcptTo[0].Host + " with " + protocol + " id " + hash + "@" + e.RcptTo[0].Host + ";\r\n"
addHead += " " + time.Now().Format(time.RFC1123Z) + "\r\n"

// data will be compressed when printed, with addHead added to beginning
Expand Down
11 changes: 9 additions & 2 deletions backends/p_header.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,18 @@ func Header() Decorator {
if len(e.Hashes) > 0 {
hash = e.Hashes[0]
}
protocol := "SMTP"
if e.ESMTP {
protocol = "E" + protocol
}
if e.TLS {
protocol = protocol + "S"
}
var addHead string
addHead += "Delivered-To: " + to + "\n"
addHead += "Received: from " + e.Helo + " (" + e.Helo + " [" + e.RemoteIP + "])\n"
addHead += "Received: from " + e.RemoteIP + " ([" + e.RemoteIP + "])\n"
if len(e.RcptTo) > 0 {
addHead += " by " + e.RcptTo[0].Host + " with SMTP id " + hash + "@" + e.RcptTo[0].Host + ";\n"
addHead += " by " + e.RcptTo[0].Host + " with " + protocol + " id " + hash + "@" + e.RcptTo[0].Host + ";\n"
}
addHead += " " + time.Now().Format(time.RFC1123Z) + "\n"
// save the result
Expand Down
3 changes: 3 additions & 0 deletions mail/envelope.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ type Envelope struct {
DeliveryHeader string
// Email(s) will be queued with this id
QueuedId string
// ESMTP: true if EHLO was used
ESMTP bool
// When locked, it means that the envelope is being processed by the backend
sync.Mutex
}
Expand Down Expand Up @@ -191,6 +193,7 @@ func (e *Envelope) Reseed(remoteIP string, clientID uint64) {
e.QueuedId = queuedID(clientID)
e.Helo = ""
e.TLS = false
e.ESMTP = false
}

// PushRcpt adds a recipient email address to the envelope
Expand Down
1 change: 1 addition & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ func (s *server) handleClient(client *client) {

case cmdEHLO.match(cmd):
client.Helo = string(bytes.Trim(input[4:], " "))
client.ESMTP = true
client.resetTransaction()
client.sendResponse(ehlo,
messageSize,
Expand Down

0 comments on commit a32e269

Please sign in to comment.