genkgo / mail

Library to send e-mails over different transports and protocols (like SMTP and IMAP) using immutable messages and streams. Also includes SMTP server.
https://mail.readthedocs.io/
Other
402 stars 21 forks source link

How to add attachments to PlainTextMessage #93

Closed riku22 closed 3 years ago

riku22 commented 3 years ago

Hello.

I started using this library. But there is one thing I don't understand. I am composing a plain text message with "PlainTextMessage". How can I add an attachment to this message? "withAttachment" doesn't seem to be available in "PlainTextMessage". If there is any good way, I would appreciate any advice.

Best regards.

frederikbosch commented 3 years ago

I think if you create a message with $bodyCollection = new MessageBodyCollection(); and then call $bodyCollection = $bodyCollection->withAlternativeText(); you can then attach attachments.

riku22 commented 3 years ago

Hello.

Thank you. I've actually tried AlternativeText, but I have one problem. AlternativeText trims some characters, such as whitespace at the end of the line. Is there a way to suppress this?

Best regards.

frederikbosch commented 3 years ago

Nope. I could add a PR to get this done next week.

riku22 commented 3 years ago

Hello.

OK. I am looking forward to it. Thank you.

Best regards.

frederikbosch commented 3 years ago

See PR #94. Will merge later today, and create a tag.

riku22 commented 3 years ago

Hello.

Thank you very much. As far as I've tried it, it seems to work as I expected. Excuse me, but let me ask you another question. * If it is better to report it as a separate issue, please point it out. AlternativeText is currently Base64 encoded, is there a way to change it to 8Bit? I'm sorry for asking so many questions.

Best regards.

frederikbosch commented 3 years ago

Sure. Can you create a separate issue with your email content (test message)? It supposed to be auto-detected which encoding to use.