Comments (8)
Hey, thanks for posting! I think it was a short term hack to test out skipping login for internal servers, actually. I didn't really use it myself, so it really is untested. You nicely pointed me to the spot though. I guess it would be nice if you'd be involved on the local server side :))))
Perhaps adding more tests to yagmail (would be really nice if we would choose a nice local server for actually sending mails and testing headers or something). Would you be interested?
As for your issue:
if smtp_skip_login:
user = ''
elif user is None:
user = self._find_user_home_path()
I think if we make that if smtp_skip_login and user is None
then that would work for now. I'll implement it, upload a new version, and then maybe you could confirm whether it works for your specific case?
Again thanks for reporting such a clear issue.
Best regards,
Pascal
from yagmail.
Please test version 0.5.148, upgrade using pip install -U --no-cache yagmail
from yagmail.
Hiya! I tested it out, and it sends! However, in Thunderbird the email shows up as from "yagmailtest@ <"WORK.com yagmailtest"@WORK.com>". I'm not sure if that's a Thunderbird thing, or if something else is going on.
Here's how I construct the object:
yag = yagmail.SMTP(user='[email protected]', host='mail.WORK.com', password=None, smtp_skip_login=True, smtp_set_debuglevel=1)
print yag.user # [email protected]
print yag.useralias # [email protected]
OK so far. But the payload looks like...
send: 'mail FROM:<[email protected]> size=1109\r\n'
reply: '250 2.1.0 Sender OK\r\n'
reply: retcode (250); Msg: 2.1.0 Sender OK
send: 'rcpt TO:<[email protected]>\r\n'
reply: '250 2.1.5 Recipient OK\r\n'
reply: retcode (250); Msg: 2.1.5 Recipient OK
send: 'data\r\n'
reply: '354 Start mail input; end with <CRLF>.<CRLF>\r\n'
reply: retcode (354); Msg: Start mail input; end with <CRLF>.<CRLF>
data: (354, 'Start mail input; end with <CRLF>.<CRLF>')
send: 'Content-Type: multipart/mixed; boundary="===============4512797292882096510=="\r\nMIME-Version: 1.0\r\nSubject: YARR YAGMAIL TEST\r\nFrom: [email protected] <[email protected]>\r\nTo: [email protected]\r\n\r\n--===============4512797292882096510==\r\nContent-Type: multipart/alternative;\r\n boundary="===============6803675811795910510=="\r\nMIME-Version: 1.0\r\n\r\n--===============6803675811795910510==\r\nContent-Type: text/plain; charset="utf-8"\r\nMIME-Version: 1.0\r\nContent-Transfer-Encoding: base64\r\n\r\nPGJyPjxicj4gICAgVGhpcyBpcyBhIG11bHRpbGluZSB0ZXN0IG1lc3NhZ2U8YnI+PGJyPiAgICBX\r\nT1JTSElQIE1FISE8YnI+PGJyPiAgICA=\r\n\r\n--===============6803675811795910510==\r\nContent-Type: multipart/related;\r\n boundary="===============5787630365189408559=="\r\nMIME-Version: 1.0\r\n\r\n--===============5787630365189408559==\r\nContent-Type: text/html; charset="utf-8"\r\nMIME-Version: 1.0\r\nContent-Transfer-Encoding: base64\r\n\r\nPGRpdj48YnI+PGJyPiAgICBUaGlzIGlzIGEgbXVsdGlsaW5lIHRlc3QgbWVzc2FnZTxicj48YnI+\r\nICAgIFdPUlNISVAgTUUhITxicj48YnI+ICAgIDwvZGl2Pg==\r\n\r\n--===============5787630365189408559==--\r\n\r\n--===============6803675811795910510==--\r\n\r\n--===============4512797292882096510==--\r\n.\r\n'
reply: '250 2.6.0 <[email protected]> [InternalId=16578075] Queued mail for delivery\r\n'
reply: retcode (250); Msg: 2.6.0 <[email protected]> [InternalId=16578075] Queued mail for delivery
data: (250, '2.6.0 <[email protected]> [InternalId=16578075] Queued mail for delivery')
send: 'quit\r\n'
reply: '221 2.0.0 Service closing transmission channel\r\n'
reply: retcode (221); Msg: 2.0.0 Service closing transmission channel
Again, I'm not sure if it's a yagmail thing or Thunderbird.
Cheers!
from yagmail.
Thanks for following up! Thunderbird also hasn't received any focus :) Your construction looks fine. I found the issue, it's getting nasty enough to warrant a new function.
On further inspection: it actually is not a bug; it has been how it is "intended".
If you do not set an alias, the header would become:
email <email>
Which is pretty awkward indeed... but we wouldn't be able to get contact info (to create something like name <email>
. So I think, even though awkward, it's the best we can do.
So that means it should all be working!
I actually do not see the problem with the payload?
from yagmail.
Hey! Sorry for the delayed response.
I did some reading and
From: [email protected] <[email protected]>
is encoded incorrectly. According to https://www.ietf.org/rfc/rfc2822.txt , the from field should match:
from = "From:" mailbox-list CRLF
mailbox-list = (mailbox *("," mailbox)) / obs-mbox-list
obs-mbox-list = 1*([mailbox] [CFWS] "," [CFWS]) [mailbox]
mailbox = name-addr / addr-spec
addr-spec = local-part "@" domain ; gonna ignore this now because that's the email bit
name-addr = [display-name] angle-addr
angle-addr = [CFWS] "<" addr-spec ">" [CFWS] / obs-angle-addr ; OK, so this is the <email@address>
display-name = phrase
obs-phrase = word *(word / "." / CFWS)
word = atom / quoted-string
atom = [CFWS] 1*atext [CFWS]
atext = ALPHA / DIGIT / ; Any character except controls,
"!" / "#" / ; SP, and specials.
"$" / "%" / ; Used for atoms
"&" / "'" /
"*" / "+" /
"-" / "/" /
"=" / "?" /
"^" / "_" /
"`" / "{" /
"|" / "}" /
"~"
So, if I read all that correctly, having a @ in the display-name is only valid if the display-name is enclosed in quotation marks. Once I add the quotation marks, the display-name shows under in my email clients as "[email protected]".
POSTFIX: Doh, I was looking at the wrong RFC! The current one in this case is https://tools.ietf.org/html/rfc5322 . I skimmed through, and the grammar for display-name should be the same.
from yagmail.
Wow, that's great. Thanks for the actual research! What about to check for@
in the display name, and if so, add quotes? Sounds like that simple logic would go a long way?
from yagmail.
Hmm. Yeah, I like that idea better. One sec, I'll redo my PR.
from yagmail.
Should be grand with PR #55 !
from yagmail.
Related Issues (20)
- Do I have to manually regenerate the OAuth2 credentials file every few days with GMail? HOT 18
- html tags yandex HOT 1
- Oauth2 refresh token expired after 7 days HOT 1
- 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
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.