Yahoo SMTP

exarkun at divmod.com exarkun at divmod.com
Mon Oct 18 01:50:47 CEST 2004


On Sun, 17 Oct 2004 16:31:38 -0700, Josiah Carlson <jcarlson at uci.edu> wrote:
>> Can someone give me an example of connecting to yahoo's smtp server 
> > and sending mail?
> > I'm doing this:
> > msg = MIMEText(self.text_ctrl_1.GetValue())
> >         msg['Subject'] = sub
> >         msg['From'] = 'bossierbossman at yahoo.com'
> >         msg['To'] = to
> >         s = smtplib.SMTP('smtp.mail.yahoo.com')
> >         s.set_debuglevel(1)
> >         s.connect()
> >         s.login('bossierbossman', 'mypassword')
> >         s.sendmail('bossierbossman at yahoo.com', [to], msg)
> >         s.quit()
> > which isn't working out for me.  Any thoughts?
> 
> Checking the source for smtplib.py, you must pass a port to
> smtplib.SMTP() if you pass a host, as it defaults to 0.

    >>> import smtplib
    >>> smtplib.SMTP.debuglevel = 1
    >>> smtplib.SMTP('foo.bar')
    connect: ('foo.bar', 25)

  Connecting to TCP port 0 makes no sense, so that would be a silly default behavior.

  Jp



More information about the Python-list mailing list