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 SetBoundary(boundary string) method #109

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

vodolaz095
Copy link

This method is used to manually set mime boundary string. If we don't call this method, the default behaviour is used - aka boundary is generated by https://godoc.org/mime/multipart package.
Also i have added unit tests to ensure it works as expected. And all old unit tests are passing.

Reason i want this method to be present, is because i have to deal with legacy report processing java application, and it hangs sometimes, when i send messages generated by your package.
As far as i understand how this java dinosaur works, it throws errors because boundary generated is 30 bytes long.

https://golang.org/src/mime/multipart/writer.go#L78

func randomBoundary() string {

	var buf [30]byte

	_, err := io.ReadFull(rand.Reader, buf[:])

	if err != nil {

		panic(err)

	}

	return fmt.Sprintf("%x", buf[:])

}

And it seems too big for java dinosaur code. Or maybe badly written regex in it... hard to say.
But if i could set boundary manually, you will make my day!
thanks

@pedromorgan
Copy link

Please check #108

@vodolaz095
Copy link
Author

and what? you propose to remake pull request to http://github.com/go-mail/mail?

@pedromorgan
Copy link

I am just pointing out that any PR's here wont go anywhere atmo, unfortunately see #104. There are a few forks, but the one above seems to have merged some of the outstanding PR's from this repos.

writeto.go Outdated
mw := multipart.NewWriter(w)
if boundary == "" {
boundary = mw.Boundary()
Copy link

@ivy ivy Feb 14, 2018

Choose a reason for hiding this comment

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

Correct me if I'm wrong, it doesn't look like there's any need for this assignment unless we decide to use it on L87 in place of mw.Boundary().

Instead, this could be expressed as:

if boundary != "" {
	mw.SetBoundary(boundary)
}

Copy link
Author

Choose a reason for hiding this comment

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

yes, thanks

@ivy
Copy link

ivy commented Feb 14, 2018

@vodolaz095 Your change looks good to me. I'd definitely like to merge it into go-mail/mail which is actively maintained.

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

Successfully merging this pull request may close these issues.

3 participants