Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add client and server support for SMTP DSN extension #135

Closed
wants to merge 2 commits into from

Conversation

foxcpp
Copy link
Collaborator

@foxcpp foxcpp commented Jan 22, 2021

Breaking change since it changes Client.Rcpt and Session.Rcpt signature.

Closes #32.

@foxcpp foxcpp marked this pull request as draft January 22, 2021 19:56
@foxcpp foxcpp marked this pull request as ready for review January 22, 2021 21:59
if err := validateLine(to); err != nil {
return err
}
if _, _, err := c.cmd(25, "RCPT TO:<%s>", to); err != nil {
cmdStr := "RCPT TO:<%s>"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it safe to just append content to cmdStr? The new content could have user-supplied %v sequences, which fmt will choke on.

We should probably set cmdStr = "RCPT TO:<%s>%s" and have a separate extStr string.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It applies to MAIL FROM too which uses similar code.

c.WriteResponse(501, EnhancedCode{5, 5, 2}, "Was expecting MAIL arg syntax of FROM:<address>")
return
}
recipient = strings.Trim(recipient, "<>")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep the TODO about this trim being not quite what we want?

Copy link
Contributor

@kayrus kayrus Jul 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also don't like the existing TODO, and proposed to use mail.ParseAddress. How is it implemented in postfix/exim mail servers? Shall we introduce a similar function?

}

for key, value := range args {
switch key {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to error out on unrecognized parameter?


for key, value := range args {
switch key {
case "ORCPT":
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a // This space is intentionally left blank comment on the next line? IMHO it's too easy to misread this as a fall-through.

@emersion
Copy link
Owner

Do you have plans to add basic test cases for these new features?

@foxcpp
Copy link
Collaborator Author

foxcpp commented Jan 30, 2021

Do you have plans to add basic test cases for these new features?

Yeah, they should be added.

@@ -71,7 +122,7 @@ type Session interface {
// Set return path for currently processed message.
Mail(from string, opts MailOptions) error
// Add recipient for currently processed message.
Rcpt(to string) error
Rcpt(to string, opts RcptOptions) error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If #145 is accepted, opts should be switched to a pointer as well.

@ikedas
Copy link
Collaborator

ikedas commented Sep 3, 2023

Hi,

I just wrote a DSN extension also: v0.18.0...ikedas:go-smtp:dsn_extension

I think my code is better in the following respects:

  • It includes the fix for PR Fix broken encodeXtext() #232 (conversely, this should be merged first).
  • Takes into account the case where SMTPUTF8 extension is enabled (update by RFC6533).
  • Doesn't include breaking changes to currect release.

Should I submit a separate PR?

@emersion
Copy link
Owner

emersion commented Sep 7, 2023

Please feel free to submit a new PR, yeah.

Do note that we can still do breaking changes to our API if we feel that they are worth it.

@emersion
Copy link
Owner

emersion commented Nov 3, 2023

Superseded by #233

@emersion emersion closed this Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DSN support
4 participants