I'm trying to write a program that sends PDFs to my Kindle using SMTP.
When I send an attachment to the Kindle using a regular client (i.e. Outlook), I get the correct file name even if it's non-ASCII. However, when I send it using the code, the Unicode characters are not shown correctly. I tried sending the attachment to my personal email and there was nothing wrong in it, only Kindle does not recognize the characters.
This is my attachment headers:
Content-Disposition: attachment; filename="Ø§ÙØ¶ØÙ ÙØ§ÙÙØ³ÙاÙ.pdf"
Content-Transfer-Encoding: base64
Content-Type: application/pdf; name="Ø§ÙØ¶ØÙ ÙØ§ÙÙØ³ÙاÙ.pdf"
And this is my code:
package main
import (
"log"
"gopkg.in/gomail.v2"
)
func main() {
m := gomail.NewMessage()
m.SetHeader("To", "MY-KINDLE-EMAIL@kindle.com")
m.SetHeader("From", "MY-EMAIL@hotmail.com")
m.SetBody("text/plain", "")
path := "C:\\Users\\al111\\Downloads\\Telegram Desktop\\كيف تعمل الماركسية.pdf"
m.Attach(path)
d := gomail.NewDialer("smtp.live.com", 587, "MY-EMAIL@hotmail.com", "MY-PASSWORD")
err := d.DialAndSend(m)
if err != nil {
log.Fatal(err)
}
}