473,386 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 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 5640
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Hank | last post by:
Hi, I have a function that sends mail but I'm finding the number of characters in the To: field is limited to ~255 characters. This means that email is sent to only part of the email list. ...
1
by: Wayne Pierce | last post by:
I have a script that checks a POP3 mailbox and sends the emails to different people based upon some settings. For some reason my script cannot send any emails, the error I am getting is: reply:...
0
by: David Geller | last post by:
Hi, I had been using smptlib to send email via my covad relay previously (several months ago), and it worked fine. Covad requires authentication, and this was accomplished fine with...
12
by: Chris Dewin | last post by:
Hi. I've been thinking about using smtplib to run a mailing list from my website. s = smtplib.SMTP("server") s.sendmail(fromaddress, toaddresess, msg) I know that in this instance, the...
1
by: Cantekin Guneser | last post by:
i try to send mail in my wep application, i use code below private void B_Ok_Click(object sender, System.EventArgs e) { MailMessage msg = new MailMessage(); msg.To =...
3
by: Chris Thunell | last post by:
I am using the following code to send email out in a vb.net web program through an exchange 2003 server. My web server is on a separate server. When i try to send email inside the office, it works...
8
by: NicolasG | last post by:
I'm using the following code to send e-mail through python: import smtplib fromaddr = 'myMail@gmail.com' toaddrs = 'myOtherMail@gmail.com' subject = 'someting for subject !' msg = 'This...
0
by: Roger | last post by:
I am having a problem sending email through smtp.gmail.com using smtplib. Everything works and the mail is sent and received, except quit. The following shows the problem (without bothering to...
0
by: 7stud | last post by:
On May 17, 12:18 pm, cher <cheryl.gi...@comcast.netwrote: Can you get the following program to work? #Uses gmail to send an email to someone import smtplib sender = "Tom"
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.