git » chasquid » commit 927a74a

Improve handling of <> addresses

author Alberto Bertogli
2016-09-25 14:57:07 UTC
committer Alberto Bertogli
2016-10-09 23:51:04 UTC
parent 0bf5d9b24220ffda68d103b1843815ffd6eae065

Improve handling of <> addresses

We can send and received with a <> "mail from", which is explicitly allowed.

Internally, we use "<>" to represent it. This requires special-casing in a
couple of places, but makes sure the handling is explicit, and we don't
accidentally confuse it with not having a source address.

This patch fixes some inconsistencies with this handling.

internal/courier/smtp.go +4 -0

diff --git a/internal/courier/smtp.go b/internal/courier/smtp.go
index 7410f4d..5ef5c4b 100644
--- a/internal/courier/smtp.go
+++ b/internal/courier/smtp.go
@@ -100,6 +100,10 @@ retry:
 	// Go's smtp does not allow us to do this, so leave for when we do it
 	// ourselves.
 
+	// c.Mail will add the <> for us when the address is empty.
+	if from == "<>" {
+		from = ""
+	}
 	if err = c.Mail(from); err != nil {
 		return tr.Errorf("MAIL %v", err), false
 	}