smtplib does not send to all recipients

2005-04-11 Thread dccarson
Here is a snippet of code which does not send to all recipients.
However, it also does not inform me of this error.  My suspicion is
that this only fails for users with longer usernames.  The two I seem
to regularly fail on have 9 and 11 characters respectively.  Most users
have names <= 8 characters.

domain = "myDomainHere.com"
admin  = "[EMAIL PROTECTED]" % domain
adminFull  = "Full Name Here <%s>" % admin
def mailMsg(text, subject, sender, recipients):
# From: and To: headers at the start!
if not sender:
sender = adminFull
elif not sender.endswith(domain):
sender += ("@" + domain)
addresslist = []
for name in recipients:
if not name.endswith(domain):
name += ("@" + domain)
addresslist.append(name)
msg = "From: %s\r\nTo: %s\r\n" % (sender, ", ".join(addresslist))
msg += "Subject: %s\r\n\r\n" % subject
for line in text.split('\n'):
msg += "%s\r\n" % line.rstrip()

try:
server = smtplib.SMTP('localhost')
server.set_debuglevel(0)
failures = server.sendmail(sender, recipients, msg)
if len(failures):
safeMailMsg("%s\n\n%s" % (failures, msg),
"ttLadder: sent with failures", [admin])
server.quit()
except smtplib.SMTPSenderRefused, sndErr:
safeMailMsg("%s\n\n%s" % (sndErr, msg),
"ttLadder: sender refused", [admin])
except smtplib.SMTPRecipientsRefused, rcpErr:
safeMailMsg("%s\n\n%s" % (rcpErr, msg),
"ttLadder: recipients refused", [admin])
except Exception, xcp:
safeMailMsg("%s\n\n%s" % (xcp, msg),
"ttLadder: other exception", [admin])
return

The safeMailMsg() routine uses os.system("mail...").  It works but it
is not sending me any error in this case.

When I test by sending the same mail to myself (7 characters) and a
long name (11 characters), I receive the e-mail but the other user does
not.  However, the header in the mail looks correct and if I do a
"Reply-all" it will happily send the mail to both of us.

Is this a known problem with older versions of smtplib?  I'm using
Python 2.2.2.

Thanks,
David

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: smtplib does not send to all recipients

2005-04-11 Thread dccarson
I changed debuglevel to 1 and looked at the response on the recipient
names.  They are BOTH accepted, but still only my id (d123456) receives
the e-mail.  The long id (d1234567890) never gets the e-mail.  Here is
the excerpt of the exchange.

send: 'mail FROM:<[EMAIL PROTECTED]> size=160\r\n'
reply: '250 2.1.0 <[EMAIL PROTECTED]>... Sender ok\r\n'
reply: retcode (250); Msg: 2.1.0 <[EMAIL PROTECTED]>... Sender
ok
send: 'rcpt TO:\r\n'
reply: '250 2.1.5 ... Recipient ok\r\n'
reply: retcode (250); Msg: 2.1.5 ... Recipient ok
send: 'rcpt TO:\r\n'
reply: '250 2.1.5 ... Recipient ok\r\n'
reply: retcode (250); Msg: 2.1.5 ... Recipient ok

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: smtplib does not send to all recipients

2005-04-13 Thread dccarson
That seems reasonable.  However, using the 'mail' utility I can deliver
the same mail successfully.  I assume mail is using sendmail under the
covers, which is doing the same negotiation with the same SMTP server?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: smtplib does not send to all recipients

2005-04-14 Thread dccarson
OK, I've discovered the lost messages, but I'm still slightly confused
as to why they ended up there.  The messages were being delivered to
the local machine, box1.domain.com, even though I was addressing them
to @domain.com.

My past experience with smtp mail has been that if I addressed the
domain explicitly, the mail would not stop at the local machine.  This
is in fact why the 'mail' utility is working.  If I use 'mail' to mail
something to  with no domain, it goes to the local machine, as I
would expect, but addressed to @domain.com, it goes to the
corporate server.

So why does smtplib deliver to box1.domain.com?  If the local smtp at
box1.domain.com is configured such that this is correct behavior, I
guess I'd expect the 'mail' utility to do the same thing when handling
address @domain.com.

By the way, the long vs. short usernames was a red herring.  Those with
.forward files were getting their mail.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ImportError: libclntsh.so.10.1: cannot open shared object file: Permission denied

2006-07-27 Thread dccarson
I have a similar question (importing cx_Oracle, but not related to
cron).  I would like to use solution #2 below and it does not work.  If
I set LD_LIBRARY_PATH before running python, it works.  If I try to set
it via os.environ, it does not work.

I have tried this in an interactive Python shell.  I can print the
value of os.environ["LD_LIBRARY_PATH"] and it is correct, but the
import fails.  The cx_Oracle.so file is found, but when it tries to
load the necessary Oracle library (libclntsh.so.9.0), I get the
message:

  ImportError: libclntsh.so.9.0: cannot open shared object file: No
such file or directory

Is there something else I have to do when changing os.environ before
trying the import?

Thanks,
David
P.S. Please post, as I don't read this e-mail account.

Damjan wrote:

> These environment variables are important for running any programs that use
> the oracle client libraries. The problem you have is that when you run the
> script from cron these environment variables are not set.
>
> Now, there are several ways how to handle this:
> 1. create a shell script that you call from cron, and it it set the
> environment variables and then call you python program
>
> 2. modify the environment in your python program (via os.environ) and then
> import cx_Oracle
>
> 3. modify your system so that no environment variables are neccesseary -
> actually this is not possible, but what I have is, symbolic links
> in /usr/lib to the libraries in $ORACLE_HOME/lib, thus I don't need the
> LD_LIBRARY_PATH variable, and the only other variable I need is the
> ORACLE_HOME, which is /usr/share/oracle on my system and it contains
> bin/  install/  lib/  network/  ocommon/  oracore/  rdbms/  sqlplus/
> 
> 
> 
> 
> -- 
> damjan

-- 
http://mail.python.org/mailman/listinfo/python-list