471,354 Members | 2,085 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 software developers and data experts.

smtplib problem, Unable to relay for

Hi,

i get an "Unable to relay for" when trying to send an email from within
my network to an email address not on my domain.
I don't understand why it says "relaying" as i'm sending from an
internal domain user to an external user.
Email server is exchange 2003

See this trace
>>smtp.sendmail("in**@mydomain.be", ["us**@externaldomain.com"], msg)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python25\Lib\smtplib.py", line 695, in sendmail
raise SMTPRecipientsRefused(senderrs)
smtplib.SMTPRecipientsRefused: {'us**@externaldomain.com': (550, '5.7.1
Unable to relay for us**@externaldomain.com')}

The smpt var is this:
smtp = smtplib.SMTP(server) where server is my mail server

I can mail to any user that is part of mydomain.be but as soon as i try
an external address, i get the "Unable to relay" message.

With a mail program it works but i need to be able to do it via code.
I thought that i would have to authenticate (smtp.login) to our mail
server but that didn't resolve the issue

Any idea how i could do this?

Thanks
Benedict

Dec 21 '07 #1
1 5190
On 2007-12-21, Benedict Verheyen <be***************@gmail.comwrote:
i get an "Unable to relay for" when trying to send an email
from within my network to an email address not on my domain. I
don't understand why it says "relaying" as i'm sending from an
internal domain user to an external user.
You're asking the SMTP server to accept mail for a user that's
not local to that server. That's relaying.
Email server is exchange 2003
Ah, well, that's too bad. You can probably get it to work
anyway...
See this trace
>smtp.sendmail("in**@mydomain.be", ["us**@externaldomain.com"], msg)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python25\Lib\smtplib.py", line 695, in sendmail
raise SMTPRecipientsRefused(senderrs)
smtplib.SMTPRecipientsRefused: {'us**@externaldomain.com': (550, '5.7.1
Unable to relay for us**@externaldomain.com')}

The smpt var is this:
smtp = smtplib.SMTP(server) where server is my mail server

I can mail to any user that is part of mydomain.be but as soon
as i try an external address, i get the "Unable to relay"
message.

With a mail program it works
With what "mail program"? Outlook? Outlook doesn't use SMTP
to send mail, so it doesn't matter what works or doesn't work
in Outlook. If relaying does work with other SMTP clients, then
comparing a TCP trace of a program that works with one from a
program that doesn't work would be very informative.
but i need to be able to do it via code.
You can use Python to send e-mails via Outlook if you want to
do that instead of using SMTP. However, Microsoft has crippled
Outlook's automation interface in a half-witted and mostly
ineffectual attempt to plug security holes. So, you have to
jump through a hoop to bypass Microsoft Outlook's security
stuff (it's not really hard to bypass -- big surprise there).
Googling for "python sending mail with outlook" will find you
all sorts of examples.
I thought that i would have to authenticate (smtp.login) to
our mail server but that didn't resolve the issue

Any idea how i could do this?
Ask the Exchange admin to enable relaying. But, (this is
_very_important_) make sure he limits relaying so that it only
relays mail accepted from the _internal_ network. If you
allowing relaying of mail accepted from outside hosts (to
outside hosts), you'll be used by spammers and criminals for
all sorts of evil, mischief, and crime.

--
Grant Edwards grante Yow! I'm rated PG-34!!
at
visi.com
Dec 22 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Hank | last post: by
1 post views Thread by Wayne Pierce | last post: by
reply views Thread by David Geller | last post: by
12 posts views Thread by Chris Dewin | last post: by
1 post views Thread by Cantekin Guneser | last post: by
3 posts views Thread by Chris Thunell | last post: by
8 posts views Thread by NicolasG | last post: by
reply views Thread by 7stud | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.