smtplib question

Tim Williams tim at tdw.net
Tue Jan 16 12:59:43 EST 2007


On 16/01/07, gandalf gold <gantgold at yahoo.com> wrote:
>
> Hi everyone,
>
> I was trying out smtplib and found out that I can email to anyone in my
> domain but not to an email address not in the domain. From browsing on the
> web, it seems that this has to do with the configuration of the mail server.
> The mail server in my organization is MS exchange. Obviously I can email to
> any email address from my MS outlook.
>
> What's the easiest way to fix the program?
>
> Thanks.
>
> - gan
>
> import sys, smtplib
> fr = "xxx at yyy.com"
> to = "xxx at zzz.com" # will not work
> line = "testing"
> subj = "subject line"
> msg = "From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n%s" % (fr, to, subj, line)
> server = smtplib.SMTP("EXCHCLUSTER.ccis.edu")
> server.set_debuglevel(1)
> server.sendmail(fr, [to], msg)
> server.quit()
>

You will need to get smtplib to authenticate when connecting to the
exchange server.    Use the login function and the same username/pw
that you use to login to Outlook.

server.login(user, password)

Note: Your exchange administrator may have disabled this function.  (
Your Outlook will almost certainly be using MAPI not SMTP to talk to
the server).

HTH :)



More information about the Python-list mailing list