Giter Club home page Giter Club logo

Comments (8)

kootenpv avatar kootenpv commented on May 10, 2024

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.

kootenpv avatar kootenpv commented on May 10, 2024

Please test version 0.5.148, upgrade using pip install -U --no-cache yagmail

from yagmail.

nfg avatar nfg commented on May 10, 2024

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.

kootenpv avatar kootenpv commented on May 10, 2024

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.

nfg avatar nfg commented on May 10, 2024

Hey! Sorry for the delayed response.

I did some reading and

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.

kootenpv avatar kootenpv commented on May 10, 2024

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.

nfg avatar nfg commented on May 10, 2024

Hmm. Yeah, I like that idea better. One sec, I'll redo my PR.

from yagmail.

nfg avatar nfg commented on May 10, 2024

Should be grand with PR #55 !

from yagmail.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.