Logo Search packages:      
Sourcecode: sabnzbdplus version File versions

def sabnzbd::utils::ssmtplib::SMTP_SSL::connect (   self,
  host = 'localhost',
  port = 0 
)

Connect to an SMTP server using SSL.

`host' is localhost by default. Port will be set to 465 (the default
SSL SMTP port) if no port is specified.

If the host name ends with a colon (`:') followed by a number, 
that suffix will be stripped off and the
number interpreted as the port number to use. This will override the 
`port' parameter.

Note: This method is automatically invoked by __init__, if a host is
specified during instantiation.

Definition at line 81 of file ssmtplib.py.

00081                                                  :
            """Connect to an SMTP server using SSL.

            `host' is localhost by default. Port will be set to 465 (the default
            SSL SMTP port) if no port is specified.

            If the host name ends with a colon (`:') followed by a number, 
            that suffix will be stripped off and the
            number interpreted as the port number to use. This will override the 
            `port' parameter.

            Note: This method is automatically invoked by __init__, if a host is
            specified during instantiation.
            """
            # MB: Most of this (Except for the socket connection code) is from 
            # the SMTP.connect() method. I changed only the bare minimum for the 
            # sake of compatibility.
            if not port and (host.find(':') == host.rfind(':')):
                  i = host.rfind(':')
                  if i >= 0:
                        host, port = host[:i], host[i+1:]
                        try: port = int(port)
                        except ValueError:
                              raise socket.error, "nonnumeric port"
            if not port: port = SSMTP_PORT
            if self.debuglevel > 0: print>>stderr, 'connect:', (host, port)
            msg = "getaddrinfo returns an empty list"
            self.sock = None
            for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
                  af, socktype, proto, canonname, sa = res
                  try:
                        self.sock = socket.socket(af, socktype, proto)
                        if self.debuglevel > 0: print>>stderr, 'connect:', (host, port)
                        self.sock.connect(sa)
                        # MB: Make the SSL connection.
                        sslobj = socket.ssl(self.sock, self.keyfile, self.certfile)
                  except socket.error, msg:
                        if self.debuglevel > 0: 
                              print>>stderr, 'connect fail:', (host, port)
                        if self.sock:
                              self.sock.close()
                        self.sock = None
                        continue
                  break
            if not self.sock:
                  raise socket.error, msg

            # MB: Now set up fake socket and fake file classes.
            # Thanks to the design of smtplib, this is all we need to do
            # to get SSL working with all other methods.
            self.sock = smtplib.SSLFakeSocket(self.sock, sslobj)
            self.file = smtplib.SSLFakeFile(sslobj);

            (code, msg) = self.getreply()
            if self.debuglevel > 0: print>>stderr, "connect:", msg
            return (code, msg)

      def setkeyfile(self, keyfile):


Generated by  Doxygen 1.6.0   Back to index