How can I send mail to 'Cc'address in smtplib?

junwon,Seo linuxqna at chollian.net
Fri Oct 20 09:01:17 EDT 2000


First, mycode follows..
Each address is string. Examply "python at python.org
mailto:python1. at python.org"
If each address contain Space, Space mean multiuser send..
But, 'Cc'address isn't running.
How can I send mail to 'Cc' address?


-------------------------------------------------
import smtplib
import string

class smtp:
 def __init__(self, fromadr, toadrs, ccadrs, subject, body):
  self.smtphost = 'ns.philemon.co.kr'
  self.server = smtplib.SMTP(self.smtphost)
  self.fromadr = fromadr
  self.toadrs = string.split(toadrs)
  self.ccadrs = string.split(ccadrs)
  self.subject = subject
  self.body = body
  self.rfc822 = self.getrfc822()

 def getrfc822(self):
  envelop = ('From: %s\r\nTo: %s\r\nCc: %s\r\nSubject: %s\r\n\r\n' %
(self.fromadr, string.join(self.toadrs,', '), string.join(self.ccadrs,', '),
self.subject))
  return envelop + self.body

 def send(self):
  self.server.sendmail(self.fromadr, self.toadrs, self.rfc822)
  self.server.quit()

mymail = smtp('fromaddress','toadrs','ccadrs','subject','body')
mymail.send()
-------------------------------------------------






More information about the Python-list mailing list