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

How to send the whole html page with the text/html contentType. #122

Open
shuangyangqian opened this issue Aug 3, 2018 · 2 comments
Open

Comments

@shuangyangqian
Copy link

shuangyangqian commented Aug 3, 2018

Hi, everyone:
when i use gmail to send a email, i choose the text/html contentType. And the body string i edit a whole html string. But i only receive the body that i send with the gomail.

the code is:
`
package main

import (
"github.com/go-gomail/gomail"
"crypto/tls"
)

func main() {
m := gomail.NewMessage()
m.SetAddressHeader("From", "xxx@xx.com", "test")
m.SetHeader("To", "xxx@xxx.com")
htmlBody := <html> <head><title>this is a title</title></head> <body><h1>Hello world</h1></body>
m.SetBody("text/html", htmlBody)
d := gomail.NewDialer("xxx.xxx.com", 123, "xxx@xx.com", "xxx")
d.TLSConfig = &tls.Config{InsecureSkipVerify: true}
d.DialAndSend(m)
}
`

the email which i received is only the

Hello world

.
why the title--this is a title in the html head is ignored.

@davleb
Copy link

davleb commented Aug 17, 2018

It is very normal for me, not a bug. Web client is not a web browser.
In the context of a mail, the subject is the title, you set it as any other header:
m.SetHeader("Subject", "Newsletter from your prefered online shop").
m.SetBody only takes ... the body part of your html ! Not strange.
Another limitation is that you cannot probably "css style" the content of the body since it is done using the HEAD balise, not the BODY. This is more problematic for me.

@pedromorgan
Copy link

see #104 and #108

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