473,322 Members | 1,259 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,322 software developers and data experts.

Server.sendmail with no "to_addrs" parameter.

Hi all, I have searched the group with no answer to this particular
problem.

In my sendmail program, I would like to have the ability to send a mail
message with no-one email address in the To field.

I do this by adding the mail to the CC field via a header. However, by
the time I get to the point of sending the mail, my recipient list is
now empty, so I get the "SMTPRecipientsRefused" error.

Looking at smtplib.py, this error is raised by:
if len(senderrs)==len(to_addrs):
# the server refused all our recipients
self.rset()
raise SMTPRecipientsRefused(senderrs)

So, being a "fool" I removed this check. I then got the next error, as
self.data(msg) had unexpected data.

Can anyone suggest how I can get round this? I have attempted numerous
things, like making my recipient list = [''], but Exchange then tried
to send the mail to "no**@mydomain.local" .

Any help would be greatly received.

Cheers
Ed

Mar 22 '06 #1
9 2980
> Can anyone suggest how I can get round this? I have attempted numerous
things, like making my recipient list = [''], but Exchange then tried
to send the mail to "no**@mydomain.local" .


rfc822: Note that the "Bcc" field may be empty, while the "To"
field
rfc822: is required to have at least one address.

Mar 22 '06 #2
So it's a restriction of Python?

What I am trying to simulate here is the sending of mail to addresses
solely in the CC and/or BCC fields - both of which are possible through
Outlook.

Mar 22 '06 #3
EdWhyatt wrote:
I would like to have the ability to send a mail
message with no-one email address in the To field.


The to_addrs parameter is for the SMTP "RCPT TO", which must contain at
least one address. It has nothing to do with the To: header of the email.

You can *also* add the recipient addresses to either of the Cc: or To:
header fields as necessary, or leave them out of any header (the equivalent
of adding the addresses to the Bcc: field.)

As Arne Ludwig pointed it, it may not be RFC compliant to leave an entirely
blank To: header, but in either case, the To: header need not contain any
of the addresses specified in the to_addrs list.
Jeffrey
Mar 22 '06 #4
Ok, totally unrelated, and on that subject, I will make sure I always
have a recipient in the To: field. - hey it works if I do that anyway!

But are you serious about that RFC Compliant thing? Can anyone shed
anymore light on this? I cannot believe that (regardless of our
opinions of them) Microsoft would allow this (un)knowingly!

Thanks to all for their comments.

Cheers
Ed

Mar 22 '06 #5
EdWhyatt wrote:
But are you serious about that RFC Compliant thing?


RFC 2822 obsoletes RFC 822, and I don't know of any specification in RFC
2822 that requires an email address to be present in the To: header. My
mail seems to generally work fine without a To: header.

I haven't memorized RFC 2822 though, so you may want to read it yourself if
you're concerned ;-)
Jeffrey

Mar 22 '06 #6
In article <qq********************************@4ax.com>,
Dennis Lee Bieber <wl*****@ix.netcom.com> wrote:
On 22 Mar 2006 08:31:16 -0800, "EdWhyatt" <ed*******@gmail.com>
declaimed the following in comp.lang.python:
So it's a restriction of Python?

RFC822 is the /standard/ (well, there are newer versions -- 2822?)
for email... It is not Python specific.
What I am trying to simulate here is the sending of mail to addresses
solely in the CC and/or BCC fields - both of which are possible through
Outlook.


Technically, then -- Outlook is in violation of the standard (you
expected Microsoft to be following standards?)


RFC822 and its followup 2822 do not require a To: address line in the
headers - rfc2822 has the minimum number listed as 0

There is a difference between the SMTP time recipient address list
(RCPT TO:) which detemines what the receiving MTA should do with the
message and the email header To:/CC:/Bcc: lines, which don't (or
should not in any working system) affect mail routing at all. You
can't get mail delivered via SMTP without a RCPT TO command at SMTP
time. Many programs extract this address, in the absence of some other
means of specifying it, by taking the addresses from the To:, CC: and
Bcc: headers, but that's a programming convenience, not an RFC
requirement. Since most people composing emails would find it annoying
to have to enter the RCPT TO addresses separately, the message
composition builds header lines, then sends the message to an MTA
using those addresses. But consider bouncing a mail - then the
desintation for SMTP is the address you are bouncing the mail to, and
the header lines are unchanged (one hopes, if not, replace your mail client)

Much as it pains me to admit it, Outlook, for all its many faults is
correct if it allows sending messages where the To: CC: and or Bcc:
headers are empty.
--
Jim Segrave (je*@jes-2.demon.nl)

Mar 22 '06 #7
In article <12*************@corp.supernews.com>,
Jeffrey Froman <je*****@fro.man> wrote:
EdWhyatt wrote:
But are you serious about that RFC Compliant thing?


RFC 2822 obsoletes RFC 822, and I don't know of any specification in RFC
2822 that requires an email address to be present in the To: header. My
mail seems to generally work fine without a To: header.

I haven't memorized RFC 2822 though, so you may want to read it yourself if
you're concerned ;-)


From RFC 2822:

The following table indicates limits on the number of times each
field may occur in a message header as well as any special
limitations on the use of those fields. An asterisk next to a
value
in the minimum or maximum column indicates that a special
restriction
appears in the Notes column.

Field Min number Max number Notes
....
to 0 1

cc 0 1

bcc 0 1

....
So the answere is, that it's not required to have any destinations
listed in the headers of the message.

It appears that it's not kosher to have an empty To: header, though
I think that few MUAs will balk at this
--
Jim Segrave (je*@jes-2.demon.nl)

Mar 22 '06 #8
"EdWhyatt" <ed*******@gmail.com> wrote:

Ok, totally unrelated, and on that subject, I will make sure I always
have a recipient in the To: field. - hey it works if I do that anyway!


OK, I'm a bit concerned that the answer to the original question has been
lost. The difference between the SMTP envelope and the message content is
an important one, and that's the key point here. If this is obvious to
everyone involved, I apologize.

The actual content of an e-mail message, including the message headers, has
absolute nothing to do with the delivery of the message. That's all just a
convention that we have developed to allow messages to be read by humans.
All of the To:, Cc:, and Bcc: headers are there for you, the human (well,
and your helper, the e-mail reader). SMTP doesn't care one whit about
them.

The smtplib.sendmail method has three parameters: sender, recipient list,
and content. SMTP could not care less about the content. You can skip ALL
of the headers (as long as you leave a blank line), and it will be
delivered just fine. It won't be RFC 822 compliant, but SMTP doesn't care.
SMTP is RFC 821. Your message will get delivered, although the recipients
e-mail reader might croak on it.

SMTP cares about the sender and the recipient list. Going off the deep
end, consider this Python snippet:

msg = """\
To: no***@nowhere.com
Subject: This is the RFC-822 part

Hello, mom!"""

s = smtplib.SMTP('localhost')
s.sendmail( "ti*@go.com", ["on*@foo.com","tw*@foo.com"], msg )

Note that the To: address is not listed in the sendmail parameters. Now,
here is a "simulated" SMTP script for this message:

MAIL FROM: <ti**@probo.com>
RCPT TO: <on*@foo.com>
RCPT TO: <tw*@foo.com>
DATA
To: no***@nowhere.com
Subject: This is the RFC-822 part

Hello, mom!
Mar 23 '06 #9
Sorry to have caused all that confusion. The quote from RFC822 I gave
is really confusing and is indeed not relevant to the original
question. As Tim pointed out, the "to_addrs" parameter in
smtplib.py::sendmail is translated to the SMTP RCPT TO and thus must
contain all the intended recipients whether they are logically To, CC,
Bcc. That parameter cannot be empty, and that is not a restriction in
Python, but a restriction of the nature of email: No recipient, no
transmission.

It is true that even with RFC 822 it was allowed to have NO To: line,
but NOT an empty To: line, while it was allowable to have an empty Bcc:
line. This was the quote I gave.

Mar 23 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: ehendrikd | last post by:
hi all i have written a php site that uses the mail() on windows and i had to state in the php.ini file which smtp server to use. have now migrated this site to a redhat 9 server, but i still...
2
by: Mark Carter | last post by:
I'm trying to create a mail server in Twisted. I either get SMTPSenderRefused or SMTPException: SMTP AUTH extension not supported by server. What do I need to do to get it to work?
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. ...
21
by: Nancy | last post by:
Hi, Guys, Is there any other way to use python or mod_python writing a web page? I mean, not use "form.py/email", no SMTP server. <form action="form.py/email" method="POST"> ... Thanks a lot. ...
2
by: Karl Ehr | last post by:
I have written the following simple program to monitor a single URL, and notify me via email whenever this URL changes. Intermittently, I raise the following exception: Traceback (most recent...
1
by: wolfing1 | last post by:
I read somewhere that server.transfer had a 2nd parameter so control and input values were 'passed' to the transferred to page, but it's giving me an error of wrong number of parameters. I have...
3
by: John Draper | last post by:
In "smtplib" module, the "sendmail" method of function is to be passed a host, but it is the Domain name for the SMTP Server as gotten from the "dig" command? IE: dig -tMX would give me the...
2
by: SAL | last post by:
Hello, I am working with Framework 1.1 and Microsoft Enterprise Library 2005. I've used the Enterprise Library Configuration utility to create my app.config & dataConfiguration.config files. ...
11
by: fdu.xiaojf | last post by:
Hi, I just want to send a very simple email from within python. I think the standard module of smtpd in python can do this, but I haven't found documents about how to use it after googleing....
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.