Send Email with Attachment
See original GitHub issueIm getting a False response from m.sendMessage()
when using attachments and I have no idea why. The print
statement returns False
when the following lines are removed it sends fine;
att = Attachment(path=filepath)
m.attachments.append(att)
example function
def email_message(username, password, dir_path):
try:
filepath = dir_path + '/filename_{}.csv'.format(str(now))
authenticiation = (username, password)
m = Message(auth=authenticiation)
att = Attachment(path=filepath)
m.attachments.append(att)
m.setRecipients("emailhere@address.com")
m.setSubject("Subject")
m.setBody("Testing")
sent = m.sendMessage()
print sent
except Exception, e:
traceback.print_exc()
print 'Sending Email Failed'
print e
return False
return sent
Issue Analytics
- State:
- Created 7 years ago
- Comments:12 (11 by maintainers)
Top Results From Across the Web
How To Write an Email With an Attachment (With Examples)
1. Determine what files you wish to send · 2. Write the email's subject line · 3. Compose the email's body · 4....
Read more >How to Send an Email with an Attachment (for Beginners)
But people who are new to email might not yet know how to attach and send files in email. Here are some beginner...
Read more >Add email attachments in Mail on iPhone - Apple Support
Attach a photo, video, or document to an email · Attach a document: Tap the Insert Attachment button above the keyboard, then locate...
Read more >How to Craft The Perfect Email with Attachments (Examples ...
An email attachment is a file accompanying an outgoing email that provides additional content not covered in your email body. The extra ...
Read more >JavaMail API - Sending Email With Attachment - Tutorialspoint
Here is an example to send an email with attachment from your machine. The file on local machine is file.txt placed at /home/manisha/....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Found it. I was using “encodebytes” to do the B64 encoding, but that method isn’t available in python 2. Fix coming soon.
@sampellino used your workaround to attach. The library still seems to be broken for me.