-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
in smtp submission, if a fromid is present in the mailfrom command, u…
…se it when queueing it's the responsibility of the sender to use unique fromid's. we do check if that's the case, and return an error if not. also make it more clear that "unique smtp mail from addresses" map to the "FromIDLoginAddresses" account config field. based on feedback from cuu508 for #31, thanks!
- Loading branch information
Showing
12 changed files
with
126 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1898,3 +1898,48 @@ test email | |
ts.smtpErr(err, &smtpclient.Error{Permanent: true, Code: smtp.C554TransactionFailed, Secode: smtp.SeMsg6Other0}) | ||
}) | ||
} | ||
|
||
// FromID can be specified during submission, but must be unique, with single recipient. | ||
func TestUniqueFromID(t *testing.T) { | ||
ts := newTestServer(t, filepath.FromSlash("../testdata/smtpfromid/mox.conf"), dns.MockResolver{}) | ||
defer ts.close() | ||
|
||
ts.user = "[email protected]" | ||
ts.pass = password0 | ||
ts.submission = true | ||
|
||
extraMsg := strings.ReplaceAll(`From: <[email protected]> | ||
To: <[email protected]> | ||
Subject: test | ||
test email | ||
`, "\n", "\r\n") | ||
|
||
// Specify our own unique id when queueing. | ||
ts.run(func(err error, client *smtpclient.Client) { | ||
tcheck(t, err, "init client") | ||
mailFrom := "[email protected]" | ||
rcptTo := "[email protected]" | ||
err = client.Deliver(ctxbg, mailFrom, rcptTo, int64(len(extraMsg)), strings.NewReader(extraMsg), true, true, false) | ||
ts.smtpErr(err, nil) | ||
}) | ||
|
||
// But we can only use it once. | ||
ts.run(func(err error, client *smtpclient.Client) { | ||
tcheck(t, err, "init client") | ||
mailFrom := "[email protected]" | ||
rcptTo := "[email protected]" | ||
err = client.Deliver(ctxbg, mailFrom, rcptTo, int64(len(extraMsg)), strings.NewReader(extraMsg), true, true, false) | ||
ts.smtpErr(err, &smtpclient.Error{Permanent: true, Code: smtp.C554TransactionFailed, Secode: smtp.SeAddr1SenderSyntax7}) | ||
}) | ||
|
||
// We cannot use our own fromid with multiple recipients. | ||
ts.run(func(err error, client *smtpclient.Client) { | ||
tcheck(t, err, "init client") | ||
mailFrom := "[email protected]" | ||
rcptTo := []string{"[email protected]", "[email protected]"} | ||
_, err = client.DeliverMultiple(ctxbg, mailFrom, rcptTo, int64(len(extraMsg)), strings.NewReader(extraMsg), true, true, false) | ||
ts.smtpErr(err, &smtpclient.Error{Permanent: true, Code: smtp.C554TransactionFailed, Secode: smtp.SeProto5TooManyRcpts3}) | ||
}) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Domains: | ||
mox.example: | ||
LocalpartCatchallSeparator: + | ||
Accounts: | ||
mjl: | ||
Domain: mox.example | ||
Destinations: | ||
[email protected]: nil | ||
FromIDLoginAddresses: | ||
- [email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
DataDir: data | ||
User: 1000 | ||
LogLevel: trace | ||
Hostname: mox.example | ||
Postmaster: | ||
Account: mjl | ||
Mailbox: postmaster | ||
Listeners: | ||
local: nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters