@J-N-K I’m having trouble using the OH2 mail binding to send an email with an attachment. Do you see anything wrong with what I’m doing below?
Here’s a code snippet.
val String imageUrl = "http://my.openhab.host:8080/static/path/to/image.jpg"
//val String imageUrl = "file:///path/to/another/image.jpg"
//val String imageUrl = "file:///path/to/a/text/file"
//val mailActions = getActions("mail","mail:smtp:gmail")
val mailActions = getActions("mail","mail:smtp:anothermailserver")
mailActions.sendMail("me@somewhere.com", "Email without attachment", "Email content without attachment")
mailActions.sendMail("me@somewhere.com", "Email with attachment", "Email content with attachment", imageUrl)
When executing the above, I get two emails. The first email correctly contains the supplied subject and content text. The second email contains the supplied subject text, but no content and no attachment.
I’ve tried this with two different mail servers with the same result.
When viewing the raw source of the second received email, this is what I see.
[snip mail headers]
Subject: Email with attachment
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_7_1653710751.1573740395359"
I’m on build 1750 with this version of the mail binding.
299 │ Active │ 80 │ 2.5.0.201911101659 │ org.openhab.binding.mail
The example in the docs shows List of attachment url strings
val List<String> attachmentUrlList = newArrayList(
"http://some.web/site/snap.jpg¶m=value",
"file:///tmp/201601011031.jpg")
val mailActions = getActions("mail","mail:smtp:sampleserver")
mailActions.sendHtmlMail("mail@example.com", "Test subject", "<h1>Header</h1>This is the mail content.", attachmentUrlList)
Yes, I did try that. And, besides, there’s no real difference between calling the API with a single url string versus the one-element list. Internally, the code converts the string url to a one element list.
I’m experiencing the same.
It worked fine in 2.5.0M2 but once I upgraded to 2.5.0M4 (I skipped M3) the images and body were no longer sent.
I upgraded to 2.5.0M5 but the result is the same.
Since I didn’t change anything in my rules I can only assume something broke.
Thanks. In the mean time I’ll look through the commits since August to see if there’s anything obvious. I took a quick look the other day, and the only thing I saw that looked material was the charset change.
sorry for the abscense… and thanks for creating an issue and following up.
I upgraded to RC1 today and rebooted and now everything works again as before.
The changes made have fixed this one for me.