Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Dennis Lee Bieber Newsgroups: comp.lang.python Subject: Re: [smtplib] how to assure login was succesful? Date: Tue, 24 May 2016 20:30:41 -0400 Organization: IISS Elusive Unicorn Lines: 34 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 8yxvK4vM85BMptXtBbX0TQKjy058/wLxtU0fzcafnFpA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:: [': 0.03; 'exception.': 0.07; 'falls': 0.09; 'message-id:@4ax.com': 0.09; 'part,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'rfc': 0.09; 'tuple': 0.09; 'python': 0.10; '(code,': 0.16; '2016': 0.16; 'ah...': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'subject:login': 0.16; 'url:home': 0.18; 'variable': 0.18; 'subject:] ': 0.19; 'not,': 0.22; 'seems': 0.23; '(where': 0.23; 'smtp': 0.23; 'this:': 0.23; 'all.': 0.24; 'sort': 0.25; 'script': 0.25; 'header:X-Complaints-To:1': 0.26; 'reaches': 0.27; 'host': 0.28; 'question:': 0.29; 'raise': 0.29; 'code': 0.30; 'skip:s 30': 0.31; 'point': 0.33; '-0700': 0.33; 'tue,': 0.34; 'server': 0.34; 'could': 0.35; 'should': 0.36; 'url:org': 0.36; 'alone': 0.36; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'method': 0.37; 'received:org': 0.37; 'charset:us-ascii': 0.37; 'skip:s 40': 0.38; 'does': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'some': 0.40; 'url:3': 0.60; 'confirm': 0.62; 'success': 0.62; 'account': 0.66; 'url:4': 0.70; 'category.': 0.84; 'dennis': 0.91; 'received:108': 0.93; 'examine': 0.95 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: adsl-108-73-116-84.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: Xref: csiph.com comp.lang.python:109096 On Tue, 24 May 2016 10:08:01 -0700 (PDT), maurice declaimed the following: >Hello to all. > >I have the following question: > >Once my python script reaches the point where I login in my email account with: server.login(username,password) (where server server = smtplib.SMTP('smtp.office365.com:587')), it returns a tuple like this: > >(235, > '2.7.0 Authentication successful target host [address here]') > >This method returns a tuple (code, resp). Just want to confirm if I use a variable to store code alone I should check if it is 235 or not, by looking at the reference it seems it is the only code value that does not raise an exception. > I would recommend you examine the RFC for SMTP to see what the return codes could be. Hmm, 235 may not be a standard response... https://tools.ietf.org/html/rfc5321#section-4.2.3 Ah... Extended codes... https://tools.ietf.org/html/rfc5248#section-2.4 https://tools.ietf.org/html/rfc4954#section-6 For the most part, any 2xx code falls into some sort of success category. -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/