v0.0.634 add ReplyTo to googleapi.SendMail
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m37s
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m37s
This commit is contained in:
@@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
// https://datatracker.ietf.org/doc/html/rfc2822
|
||||
func encodeMimeMail(from string, recipients []string, cc []string, bcc []string, subject string, body MailBody, attachments []MailAttachment) string {
|
||||
func encodeMimeMail(from string, recipients []string, cc []string, bcc []string, replyTo []string, subject string, body MailBody, attachments []MailAttachment) string {
|
||||
|
||||
data := make([]string, 0, 32)
|
||||
|
||||
@@ -22,6 +22,9 @@ func encodeMimeMail(from string, recipients []string, cc []string, bcc []string,
|
||||
if len(bcc) > 0 {
|
||||
data = append(data, "Bcc: "+strings.Join(langext.ArrMap(bcc, func(v string) string { return mime.QEncoding.Encode("UTF-8", v) }), ", "))
|
||||
}
|
||||
if len(replyTo) > 0 {
|
||||
data = append(data, "Reply-To: "+strings.Join(langext.ArrMap(replyTo, func(v string) string { return mime.QEncoding.Encode("UTF-8", v) }), ", "))
|
||||
}
|
||||
data = append(data, "Subject: "+mime.QEncoding.Encode("UTF-8", subject))
|
||||
|
||||
hasInlineAttachments := langext.ArrAny(attachments, func(v MailAttachment) bool { return v.IsInline })
|
||||
|
||||
@@ -13,6 +13,7 @@ func TestEncodeMimeMail(t *testing.T) {
|
||||
[]string{"trash@mikescher.de"},
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
"Hello Test Mail",
|
||||
MailBody{Plain: "Plain Text"},
|
||||
nil)
|
||||
@@ -27,6 +28,7 @@ func TestEncodeMimeMail2(t *testing.T) {
|
||||
[]string{"trash@mikescher.de"},
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
"Hello Test Mail (alternative)",
|
||||
MailBody{
|
||||
Plain: "Plain Text",
|
||||
@@ -44,6 +46,7 @@ func TestEncodeMimeMail3(t *testing.T) {
|
||||
[]string{"trash@mikescher.de"},
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
"Hello Test Mail (alternative)",
|
||||
MailBody{
|
||||
HTML: "<html><body><u>Non</u> Pl<i>ai</i>n T<b>ex</b>t</body></html>",
|
||||
@@ -64,6 +67,7 @@ func TestEncodeMimeMail4(t *testing.T) {
|
||||
[]string{"trash@mikescher.de"},
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
"Hello Test Mail (inline)",
|
||||
MailBody{
|
||||
HTML: "<html><body><u>Non</u> Pl<i>ai</i>n T<b>ex</b>t</body></html>",
|
||||
|
||||
@@ -19,9 +19,9 @@ type MailRef struct {
|
||||
LabelIDs []string `json:"labelIds"`
|
||||
}
|
||||
|
||||
func (c *client) SendMail(ctx context.Context, from string, recipients []string, cc []string, bcc []string, subject string, body MailBody, attachments []MailAttachment) (MailRef, error) {
|
||||
func (c *client) SendMail(ctx context.Context, from string, recipients []string, cc []string, bcc []string, replyTo []string, subject string, body MailBody, attachments []MailAttachment) (MailRef, error) {
|
||||
|
||||
mm := encodeMimeMail(from, recipients, cc, bcc, subject, body, attachments)
|
||||
mm := encodeMimeMail(from, recipients, cc, bcc, replyTo, subject, body, attachments)
|
||||
|
||||
tok, err := c.oauth.AccessToken()
|
||||
if err != nil {
|
||||
|
||||
@@ -36,6 +36,7 @@ func TestSendMail1(t *testing.T) {
|
||||
[]string{"trash@mikescher.de"},
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
"Hello Test Mail",
|
||||
MailBody{Plain: "Plain Text"},
|
||||
nil)
|
||||
@@ -66,6 +67,7 @@ func TestSendMail2(t *testing.T) {
|
||||
[]string{"trash@mikescher.de"},
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
"Hello Test Mail (alternative)",
|
||||
MailBody{
|
||||
Plain: "Plain Text",
|
||||
@@ -99,6 +101,7 @@ func TestSendMail3(t *testing.T) {
|
||||
[]string{"trash@mikescher.de"},
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
"Hello Test Mail (attach)",
|
||||
MailBody{
|
||||
HTML: "<html><body><u>Non</u> Pl<i>ai</i>n T<b>ex</b>t</body></html>",
|
||||
@@ -135,6 +138,7 @@ func TestSendMail4(t *testing.T) {
|
||||
[]string{"trash@mikescher.de"},
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
"Hello Test Mail (inline)",
|
||||
MailBody{
|
||||
HTML: "<html><body><u>Non</u> Pl<i>ai</i>n T<b>ex</b>t</body></html>",
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
type GoogleClient interface {
|
||||
SendMail(ctx context.Context, from string, recipients []string, cc []string, bcc []string, subject string, body MailBody, attachments []MailAttachment) (MailRef, error)
|
||||
SendMail(ctx context.Context, from string, recipients []string, cc []string, bcc []string, replyTo []string, subject string, body MailBody, attachments []MailAttachment) (MailRef, error)
|
||||
}
|
||||
|
||||
type client struct {
|
||||
|
||||
Reference in New Issue
Block a user