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

Ability to return custom responses? #97

Closed
oogali opened this issue May 10, 2020 · 10 comments
Closed

Ability to return custom responses? #97

oogali opened this issue May 10, 2020 · 10 comments

Comments

@oogali
Copy link

oogali commented May 10, 2020

I'd like to return custom responses in response to the execution of the Mail, Rcpt, and Data functions of the Session object.

I see I can string together my own responses using SMTPError, however the logic in the connection handling code doesn't particularly like receiving any sort of error.

Would it be against the spirit of the project if this logic was modified to further inspect SMTPError and only error out if SMTPError.Code was not 250?

@oogali
Copy link
Author

oogali commented May 10, 2020

As an example...

	return &smtp.SMTPError{
		Code:         250,
		EnhancedCode: smtp.EnhancedCode{2, 0, 0},
		Message:      fmt.Sprintf("Ok: queued as %s", queueID),
	}

@emersion
Copy link
Owner

We already allow this for a bunch of functions, see e.g.

go-smtp/conn.go

Line 451 in 689d1d4

if smtpErr, ok := err.(*SMTPError); ok {

Maybe we're missing some others

@foxcpp
Copy link
Collaborator

foxcpp commented May 10, 2020

We already allow this for a bunch of functions, see e.g.

It is not going to work correctly since s.recipients list is not being populated.

@foxcpp
Copy link
Collaborator

foxcpp commented May 10, 2020

Speaking of "spirit of the project". I believe having any useful text in success responses has marginal benefit since most (all?) client implementations will just discard it. What is the use case?

@foxcpp
Copy link
Collaborator

foxcpp commented May 10, 2020

If you have fingerprinting concerns or just do not like silly responses, we can replace it with just "Ok". :)

@emersion
Copy link
Owner

Ah, right, this is about the success reply. Not sure it's worth it to do anything complicated to support this.

@oogali
Copy link
Author

oogali commented May 10, 2020

@foxcpp The use case is more for traceability -- to be able to trace the message from the ingestion point (go-smtp) to the final delivery/handoff.

This is more for troubleshooting and monitoring rather than for consumption by any random SMTP client.

@oogali
Copy link
Author

oogali commented May 10, 2020

I'm more interested in this on DATA than any other command (to surface the internal queue ID).

@oogali oogali closed this as completed Jun 9, 2020
@gowthamgts
Copy link

@oogali - same use-case for me as well. @emersion - no plans to add this?

@kayrus
Copy link
Contributor

kayrus commented Jun 3, 2022

@oogali @gowthamgts Mail and Rcpt should be solved in #188

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants