Comments (6)
I think this has something to do with the _preparemessage function - line 217 of yagmail.py. There is a dictionary search for headers. I think we need to set headers appropriately. Initially, somewhat naively I set headers in the send function to 'alternative' but it's a dictionary and I have no idea what the key / value pairs should be; though I assume the value is the 'alternative' part.
from yagmail.
I noticed on the command line that it was complaining about missing lxml. I pip installed this (I'm using python 3 in virtualenv). However, I now see this error result:
Traceback (most recent call last):
File "etest.py", line 107, in
test_yag()
File "etest.py", line 103, in test_yag
yag.send(to=recipients, headers={'Content-Type':'text/alternative; charset=utf-8'}, subject='title', contents=contents)
File "/home/oliver/Development/item/env3/lib/python3.4/site-packages/yagmail/yagmail.py", line 98, in send
addresses, subject, contents, use_cache, headers)
File "/home/oliver/Development/item/env3/lib/python3.4/site-packages/yagmail/yagmail.py", line 213, in _prepare_message
contents, use_cache)
File "/home/oliver/Development/item/env3/lib/python3.4/site-packages/yagmail/yagmail.py", line 279, in _prepare_contents
content_object = self._get_mime_object(content)
File "/home/oliver/Development/item/env3/lib/python3.4/site-packages/yagmail/yagmail.py", line 362, in _get_mime_object
html_tree = lxml.html.fromstring(content_string)
File "/home/oliver/Development/item/env3/lib/python3.4/site-packages/lxml/html/init.py", line 726, in fromstring
doc = document_fromstring(html, parser=parser, base_url=base_url, *_kw)
File "/home/oliver/Development/item/env3/lib/python3.4/site-packages/lxml/html/init.py", line 614, in document_fromstring
value = etree.fromstring(html, parser, *_kw)
File "lxml.etree.pyx", line 3103, in lxml.etree.fromstring (src/lxml/lxml.etree.c:70569)
File "parser.pxi", line 1828, in lxml.etree._parseMemoryDocument (src/lxml/lxml.etree.c:106403)
File "parser.pxi", line 1709, in lxml.etree._parseDoc (src/lxml/lxml.etree.c:105106)
File "parser.pxi", line 1047, in lxml.etree._BaseParser._parseUnicodeDoc (src/lxml/lxml.etree.c:99534)
File "parser.pxi", line 580, in lxml.etree._ParserContext._handleParseResultDoc (src/lxml/lxml.etree.c:94350)
File "parser.pxi", line 690, in lxml.etree._handleParseResult (src/lxml/lxml.etree.c:95786)
File "parser.pxi", line 631, in lxml.etree._raiseParseError (src/lxml/lxml.etree.c:95065)
lxml.etree.XMLSyntaxError: None
I had previously updated the send method to include headers={'Content-Type':'text/alternative;charset=utf-8'}
from yagmail.
Note that removing the headers parameter produces the same result. It seems the lxml dependency breaks yagmail in it's current form.
from yagmail.
Thanks for taking the time/effort to report your findings!
I can reproduce the lxml bug when you set the first arguments of the list (instead of the filename in this case) to ''
.
It tries to parse ''
which fails.
Though, please, contents can be mixed and it would make no sense to add ''
to it (though I will take care of it; it could happen legitimately in some templating. If you want to send a message AT THIS MOMENT just don't use ''
as an argument).
"First argument" in this case (filename) is nothing special, just omit it.
# works
contents = ['/local/file.png', 'some text',
'<b><a href="https://github.com/kootenpv/yagmail">a link</a></b>']
# works
contents = ['some text', '<b><a href="https://github.com/kootenpv/yagmail">a link</a></b>']
# doesn't work
contents = ['', 'some text',
'<b><a href="https://github.com/kootenpv/yagmail">a link</a></b>']
from yagmail.
Thanks for the advice and very swift response to all my issues. The problem is resolved if I remove '' as the first parameter as you described which is great, thanks.
from yagmail.
Great, I'll regard it as closed!
from yagmail.
Related Issues (20)
- App Password not available for my gmail account. How should I authenticate? HOT 4
- Error report while start my application HOT 4
- Sending smtp with starttls HOT 4
- Send fails with pyinstaller only when contents is added HOT 3
- Can't install HOT 4
- AttributeError: partially initialized module 'yagmail' has no attribute 'SMTP' (most likely due to a circular import) HOT 1
- yagmail支持获取邮件内容吗 HOT 1
- Sending the same email with different attachments to different recipients but the script stops running after 3-4 iterations every time and also the first few mails take 10-15 seconds to send each
- difficulty getting oauth file with yagmail HOT 4
- sending unwated attachments. HOT 2
- 只能发送邮件,不能接收邮件吗? HOT 1
- Keyring is Locked on Ubuntu HOT 2
- Send mail in draft
- Slow sending HOT 1
- smtplib.SMTPDataError: (550, b'2efb645ddd8af6f-15f8b Mail rejected')
- MailServerError
- Is this sill maintained ? No commit in the past year HOT 1
- It throws an exception when running on windows 10 cmd.exe after packed into an .exe script by pyinstaller command HOT 1
- issues with content display
- Send identical email with same content multiple times to same address [sending email occasionally works]
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yagmail.