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

fix mail attachment name garbled #83

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

Conversation

LYY
Copy link

@LYY LYY commented Apr 20, 2017

Fix #66 , add mail's charset for attachments.

.gitignore Outdated
@@ -0,0 +1 @@
.vscode
Copy link

Choose a reason for hiding this comment

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

Many maintainers dislike the addition of editor-specific ignores. Please use a global .gitignore to ignore your editor's project files.

Copy link
Author

Choose a reason for hiding this comment

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

Ok, I fixed it. But this project is under maintenance yet?

@Tom-Kail
Copy link

Tom-Kail commented Jul 10, 2017

Thanks for fixing the garbled bug,but I find a way to fix it without changing code

        m := gomail.NewMessage()
	m.SetHeader("From", "big brother <[email protected]>")
	m.SetHeader("To", "[email protected]")
	//	m.SetAddressHeader("Cc", "[email protected]", "Dan")
	m.SetHeader("Subject", "请注意")
	m.SetBody("text/html", "明天下午在大会议室见面")
	f, err := os.Create("重要的文件呦.txt")
	if err != nil {
		panic(err)
	}

	defer func(name string) {
		time.Sleep(time.Second * 10)
		os.Remove(name)
	}(f.Name())

	defer f.Close()
	f.WriteString("这是一个不能说的秘密")
	h := make(map[string][]string, 0)
	h["Content-Type"] = []string{`application/octet-stream; charset=utf-8; name="` + f.Name() + `"`} //要设置这个,否则中文会乱码
	//	h["Content-Type"] = []string{`text/plain; name="` + f.Name() + `"`}
	fileSetting := gomail.SetHeader(h)
	m.Attach(f.Name(), fileSetting)
	d := gomail.NewDialer("smtp.example.com", 25, "[email protected]", "password")
	d.TLSConfig = &tls.Config{InsecureSkipVerify: true}
	fmt.Println("================")
	if err := d.DialAndSend(m); err != nil {
		panic(err)
	}
	fmt.Println("结束")

@h3110w0r1d
Copy link

it does not work for me

@LYY
Copy link
Author

LYY commented Oct 30, 2017

@h3110w0r1d Can you give me some more infomations about your problem?

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.

5 participants