KostyaEsmukov/smtp_to_telegram

Unable to receive images in telegram

duanedtp opened this issue · 1 comments

System works but i'm unable to receive or pull images from the email. I'm using this to relay motion events from my security cameras, which takes a snapshot and attaches it to the email. Is it a formatting issue?

HTML and attachments are not supported, only plaintext is being forwarded, see

func TestHtmlAttachmentIsIgnored(t *testing.T) {
smtpConfig := makeSmtpConfig()
telegramConfig := makeTelegramConfig()
d := startSmtp(smtpConfig, telegramConfig)
defer d.Shutdown()
h := NewSuccessHandler()
s := HttpServer(h)
defer s.Shutdown(context.Background())
m := gomail.NewMessage()
m.SetHeader("From", "from@test")
m.SetHeader("To", "to@test")
m.SetHeader("Subject", "Test subj")
m.SetBody("text/plain", "Text body")
m.AddAlternative("text/html", "<p>HTML body</p>")
di := gomail.NewPlainDialer(testSmtpListenHost, testSmtpListenPort, "", "")
err := di.DialAndSend(m)
assert.NoError(t, err)
assert.Len(t, h.RequestMessages, len(strings.Split(telegramConfig.telegramChatIds, ",")))
exp :=
"From: from@test\n" +
"To: to@test\n" +
"Subject: Test subj\n" +
"\n" +
"Text body"
assert.Equal(t, exp, h.RequestMessages[0])
}

Converting HTML to Telegram markup would be very complex, so I don't think adding that support would be feasible.

However, simply bypassing image attachments as telegram file uploads should be easy to implement, for that a PR would be welcome.