phyllisstein / alp

A Python module for Alfred v2 workflows
174 stars 11 forks source link

Mime type problem #14

Closed danebrood closed 11 years ago

danebrood commented 11 years ago

Hey,

Looks like alp.Mail() is expecting only the mime subtype, e.g. "plain". Explained here for class MIMEText: http://docs.python.org/2/library/email.mime.html

Sending the full mimetype as shown in the readme, or using the default "text/plain", resulted in the body being an attachment.

Thanks for alp! Dan

phyllisstein commented 11 years ago

Could you explain in a bit more detail what you tried, what you expected to happen, and what happened instead? I think the use of MIMEText is appropriate, since this is only meant to be a quick-and-dirty way to send notifications, but if it's not working correctly then that's another story.

danebrood commented 11 years ago

Hey, yeah you bet.

Following the alp readme, I tried using alp.Mail(). First, I passed it mimetype = None, wanting to just have a plaintext email sent. I set it up to use gmail SMTP. I expected to receive an email, with the "body" paramater set as the email body. I received the email; there was no body, but an attachment. Opening the attachment, was the body text. The email was sent with a mimetype of "text/text/plain"

This is happening because alp's mail.py, it is passing a mimetype of "text/plain" to MIMEText. However according to the docs for MIMEText, it wants only the subtype, since it assumes a major mimetype of "text"

To fix, would just require updated line 16 of mail.py, to use a default mimetype of "plain", and then to update the readme.

Heh, sorry I didn't write up a patch in the first place, I don't know python at all so didn't want to assume, but if the above sounds right, I could do that.

phyllisstein commented 11 years ago

Aha, I understand now. Should be a pretty quick fix; I'll push a new version out in a minute and you can see if that helps.