473,698 Members | 2,392 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 "SMTPRecipients Refused" 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 SMTPRecipientsR efused(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 3006
> 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.net com.com> wrote:
On 22 Mar 2006 08:31:16 -0800, "EdWhyatt" <ed*******@gmai l.com>
declaimed the following in comp.lang.pytho n:
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.supernew s.com>,
Jeffrey Froman <je*****@fro.ma n> 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*******@gmai l.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.sendmai l 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.c om
Subject: This is the RFC-822 part

Hello, mom!"""

s = smtplib.SMTP('l ocalhost')
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.c om
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::sen dmail 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
9881
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 want the emails to be sent via the smtp server i stated earlier. this may infact be a sendmail question, im not sure, (perhaps changing sendmail_path in php.ini) but has anyone managed to send email via
2
7945
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
2108
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. #recipients is a list of email addresses, greater than 255 characters in total
21
3372
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. Nancy W
2
3010
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 call last): File "./urlwatch.py", line 34, in ? server.sendmail(sourceAddress, emailAddress, message) File "/usr/lib/python2.2/smtplib.py", line 621, in sendmail if not (200 <= self.ehlo() <= 299): File "/usr/lib/python2.2/smtplib.py", line...
1
1846
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 IIS5, is that the problem? or is it that it's an ASP page (not ASPX)
3
1716
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 SMTP server. In my code I have: try: print "Sending message to host: %s" % mailHost server=smtplib.SMTP(mailHost) server.sendmail(reply_email,email,body)
2
3174
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. My question is, why is the Enterprise Library stripping out my User Id and Password from my SQL Server connection string, that I have in the dataConfiguration file? This is an internal app that has no UI and is an automated process that runs...
11
22355
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. Are there any examples of using smtpd ? I'm not an expert,so I need some examples to learn how to use it. Or maybe there is a better way to to this?
0
8678
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9166
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9030
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2333
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.