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

incomplete functionality for Return-Path(MAIL FROM) handling #202

Open
grigorijski opened this issue Sep 13, 2024 · 9 comments
Open

incomplete functionality for Return-Path(MAIL FROM) handling #202

grigorijski opened this issue Sep 13, 2024 · 9 comments

Comments

@grigorijski
Copy link

Currently it is possible to setup MAIL FROM address (Return-Path) using "Sender" header. But in this case "Sender" header also is passed together with other headers in DATA block and is received by message recepient, which should not be the case.

Propose that separate header must be used for "Return-Path" setting so only "Return-Path" or both "Return-Path"/"Sender" could be setup

@wneessen
Copy link

Unfortunately this won't be fixed since the maintainer has sadly passed away.

You might want to consider checking wneessen/go-mail instead.

@nilansaha
Copy link

@grigorijski What do you mean by you can set return path using sender?

Isn't sender and from the same thing? Were you able to set return path? I don't care if the end user sees it.

@wneessen
Copy link

Isn't sender and from the same thing? Were you able to set return path? I don't care if the end user sees it.

No. Envelope-From and Mail Body From are different things.

Envelope-From is what is used in the SMTP protocol communication between client and server. It will be used as Return-Path e. g. if the mail cannot be delivered.

Mail body From is the address that is shown by the mail client on the receiving end.

These can differ. Let's assume you have an automatic mailing system that is connceted with your CRM. You send a mail to toni.tester@example.com and your official from address is order@company.tld. Now let's assume you want to identify mails that could not be delivered in your CRM together with an order that has been issued by the user. In this case you can set the Envelope from to bounces+<order number>@company.tld. You set order@company.tld as mail body from address. This will be shown to the user. If the mail to toni.tester@example.com now bounces because the put a typo into their address, the receiving mailserver will reject the mail. The bounce will be sent to the envelope from address - in this case bounces+<order number>@company.tld. You can configure your CRM to automatically associate the bounce mail to the order ID and let the support agent see that the mail for this specific order bounced.

@nilansaha
Copy link

nilansaha commented Nov 12, 2024

Isn't sender and from the same thing? Were you able to set return path? I don't care if the end user sees it.

No. Envelope-From and Mail Body From are different things.

Envelope-From is what is used in the SMTP protocol communication between client and server. It will be used as Return-Path e. g. if the mail cannot be delivered.

Mail body From is the address that is shown by the mail client on the receiving end.

These can differ. Let's assume you have an automatic mailing system that is connceted with your CRM. You send a mail to toni.tester@example.com and your official from address is order@company.tld. Now let's assume you want to identify mails that could not be delivered in your CRM together with an order that has been issued by the user. In this case you can set the Envelope from to bounces+<order number>@company.tld. You set order@company.tld as mail body from address. This will be shown to the user. If the mail to toni.tester@example.com now bounces because the put a typo into their address, the receiving mailserver will reject the mail. The bounce will be sent to the envelope from address - in this case bounces+<order number>@company.tld. You can configure your CRM to automatically associate the bounce mail to the order ID and let the support agent see that the mail for this specific order bounced.

Got it. So if I set the sender header in this package it will be used for the return-path?

I basically looked at this piece of code and assumed that the from here is the mail body from. But it seems its the Envelope-From?

func (m *Message) getFrom() (string, error) {
	from := m.header["Sender"]
	if len(from) == 0 {
		from = m.header["From"]
		if len(from) == 0 {
			return "", errors.New(`gomail: invalid message, "From" field is absent`)
		}
	}

	return parseAddress(from[0])
}

@wneessen
Copy link

Message.getFrom() is used for the Envelope From, yes. It checks whether Sender is set and use it. If it's not set, it will fall back to the normal mail body from address.

In wneessen/go-mail we do it similarly, but we provide direct access methods to EnvelopeFrom and From (meaning mail body from) which is, as I believe what the OP is looking for.

@nilansaha
Copy link

Message.getFrom() is used for the Envelope From, yes. It checks whether Sender is set and use it. If it's not set, it will fall back to the normal mail body from address.

In wneessen/go-mail we do it similarly, but we provide direct access methods to EnvelopeFrom and From (meaning mail body from) which is, as I believe what the OP is looking for.

Got it, thanks for sharing. Tbh I checked out your library but it seems too complicated and frankly has an API spec I don't like. This library is just clean and simple and works mostly. I wish someone made a fork with it and maintained it.

@wneessen
Copy link

Got it, thanks for sharing. Tbh I checked out your library but it seems too complicated and frankly has an API spec I don't like. This library is just clean and simple and works mostly. I wish someone made a fork with it and maintained it.

Fair enough. Out of curiosity, and we can keep this out of this thread if you like... We're always looking for feedback on how to improve. What exactly makes it "too complicated" and what "API specs" to you not like? Feel free to send me a mail directly at github-gogomail-issue-202.hym3u@nop.li, so we don't spam this thread any further. If you don't wanna elaborate, that's also totally fine.

@nilansaha
Copy link

Got it, thanks for sharing. Tbh I checked out your library but it seems too complicated and frankly has an API spec I don't like. This library is just clean and simple and works mostly. I wish someone made a fork with it and maintained it.

Fair enough. Out of curiosity, and we can keep this out of this thread if you like... We're always looking for feedback on how to improve. What exactly makes it "too complicated" and what "API specs" to you not like? Feel free to send me a mail directly at github-gogomail-issue-202.hym3u@nop.li, so we don't spam this thread any further. If you don't wanna elaborate, that's also totally fine.

Hi, sorry for the delayed response. I saw this when I was half asleep and forgot to respond. I would have much rather prefer the same API spec as the original gomail and new functionalities built on top of that. Also, I personally do not like this builder type API design, not everything has to be New or with. Its a very JAVA style design and not idiomatic to Go imo.

@wneessen
Copy link

Fair enough. Thanks for the feedback. Just as a sidenote, I recently introduced a "QuickSend" method that doesn't require all of the "New" and "With" stuff. Maybe that's something you are looking for: https://pkg.go.dev/github.com/wneessen/go-mail@v0.5.3-0.20241122153610-ead4067f2dd8#QuickSend

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

3 participants