smtplib sendmail problems

H

Hank

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

header = "To: " + string.join(recipients, "; ") + "\r\n" \
"From: " + "(e-mail address removed)\r\n" \
"Date: " + time.strftime("%A, %B %d, %Y %I:%M %p",
sendTime)+ "\r\n"
"X-Mailer: Automated Test \r\n" \
"Subject: " + subject + "\r\n\r\n"
text = header + mailText
server = smtplib.SMTP('something.something.com')
result = server.sendmail("(e-mail address removed)", recipients, text)
server.quit()


Any help is greatly appreciated.

Thanks
 
P

Peter Hansen

Hank said:
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

header = "To: " + string.join(recipients, "; ") + "\r\n" \
"From: " + "(e-mail address removed)\r\n" \
"Date: " + time.strftime("%A, %B %d, %Y %I:%M %p",
sendTime)+ "\r\n"
"X-Mailer: Automated Test \r\n" \
"Subject: " + subject + "\r\n\r\n"
text = header + mailText
server = smtplib.SMTP('something.something.com')
result = server.sendmail("(e-mail address removed)", recipients, text)
server.quit()

What does "recipients" contain? That's the relevant thing here,
not the To: header.

SMTP does not use the To: header for any purpose. In fact, it can
be absent. If only some people are receiving your message, it is
something to do with the recipients list (note: it must be a list)
and not the header. Or there's a problem with an intermediate
mail relay. Or something else. Always lots of ways for this stuff
to fail except, generally, the To: header.

-Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top