Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
MailMessage can not send mails with attachment in Pharo7 #3163
In Pharo 7 it is no longer possible to send mails with an attachment with MailMessage.
In Pharo7, the mail is sent but the file attached is empty.
After a lot of investigating I found the reason. In MailMessage>>regenerateText, this code causes the problem
Explanation: In case of an attachment, the decoderClass is not nil and encodedBodyText will be a Stream.
With the original code, the mailText is generated like this:
You see-> the file contents is missing
Now I change the method MailMessage>>regenerateText (last line) to
then the same test code results in this
Yes, this is also what I did recently, send #contents to the readStream in MailMessage>>#regenerateText
It also took me some time to understand what was happening ;-)
I was just a bit unsure about the solution, as it felt more like a hack, and I was in a hurry.
Since we have now two similar fixes, it will probably be OK.
Hi @SabineMa ,
MailMessage uses MIMEDocument internally, which is extremely limited in its functionality.
I started to use ZnMimePart instead, but then got sidetracked on other projects. If you find yourself needing to extend MIMEDocument you might like to think about switching to ZnMimePart.
Sorry for the slow reply. I haven't looked directly at integrating MailMessage with ZnMimePart, but... MailMessage uses MIMEDocument to hold the body of the message. From memory, MailMessage simply passes the source document off to MIMEDocument to parse, so it shouldn't be too difficult to replace MIMEDocument with ZnMimePart. MIMEDocument is missing a lot of functionality, and adding the missing functionality would largely duplicate what ZnMimePart and friends already does. So I think any effort would be much better value by working on replacing MIMEDocument with ZnMimePart.