mailmerge.py (a0292563) | mailmerge.py (d3d1f4e0) |
---|---|
1# Caolan McNamara caolanm@redhat.com 2# a simple email mailmerge component 3 4# manual installation for hackers, not necessary for users 5# cp mailmerge.py /usr/lib/openoffice.org2.0/program 6# cd /usr/lib/openoffice.org2.0/program 7# ./unopkg add --shared mailmerge.py 8# edit ~/.openoffice.org2/user/registry/data/org/openoffice/Office/Writer.xcu --- 26 unchanged lines hidden (view full) --- 35 36from email.MIMEBase import MIMEBase 37from email.Message import Message 38from email import Encoders 39from email.Header import Header 40from email.MIMEMultipart import MIMEMultipart 41from email.Utils import formatdate 42from email.Utils import parseaddr | 1# Caolan McNamara caolanm@redhat.com 2# a simple email mailmerge component 3 4# manual installation for hackers, not necessary for users 5# cp mailmerge.py /usr/lib/openoffice.org2.0/program 6# cd /usr/lib/openoffice.org2.0/program 7# ./unopkg add --shared mailmerge.py 8# edit ~/.openoffice.org2/user/registry/data/org/openoffice/Office/Writer.xcu --- 26 unchanged lines hidden (view full) --- 35 36from email.MIMEBase import MIMEBase 37from email.Message import Message 38from email import Encoders 39from email.Header import Header 40from email.MIMEMultipart import MIMEMultipart 41from email.Utils import formatdate 42from email.Utils import parseaddr |
43from socket import _GLOBAL_DEFAULT_TIMEOUT |
|
43 44import sys, smtplib, imaplib, poplib 45 46dbg = False 47 48class PyMailSMTPService(unohelper.Base, XSmtpService): 49 def __init__( self, ctx ): 50 self.ctx = ctx --- 15 unchanged lines hidden (view full) --- 66 def getSupportedConnectionTypes(self): 67 if dbg: 68 print >> sys.stderr, "PyMailSMPTService getSupportedConnectionTypes" 69 return self.supportedtypes 70 def connect(self, xConnectionContext, xAuthenticator): 71 self.connectioncontext = xConnectionContext 72 if dbg: 73 print >> sys.stderr, "PyMailSMPTService connect" | 44 45import sys, smtplib, imaplib, poplib 46 47dbg = False 48 49class PyMailSMTPService(unohelper.Base, XSmtpService): 50 def __init__( self, ctx ): 51 self.ctx = ctx --- 15 unchanged lines hidden (view full) --- 67 def getSupportedConnectionTypes(self): 68 if dbg: 69 print >> sys.stderr, "PyMailSMPTService getSupportedConnectionTypes" 70 return self.supportedtypes 71 def connect(self, xConnectionContext, xAuthenticator): 72 self.connectioncontext = xConnectionContext 73 if dbg: 74 print >> sys.stderr, "PyMailSMPTService connect" |
75 |
|
74 server = xConnectionContext.getValueByName("ServerName") 75 if dbg: | 76 server = xConnectionContext.getValueByName("ServerName") 77 if dbg: |
76 print >> sys.stderr, server | 78 print >> sys.stderr, "ServerName: %s" % server 79 |
77 port = xConnectionContext.getValueByName("Port") 78 if dbg: | 80 port = xConnectionContext.getValueByName("Port") 81 if dbg: |
79 print >> sys.stderr, port 80 self.server = smtplib.SMTP(server, port) | 82 print >> sys.stderr, "Port: %d" % port 83 84 tout = xConnectionContext.getValueByName("Timeout") |
81 if dbg: | 85 if dbg: |
86 print >> sys.stderr, isinstance(tout,int) 87 if not isinstance(tout,int): 88 tout = _GLOBAL_DEFAULT_TIMEOUT 89 if dbg: 90 print >> sys.stderr, "Timeout: %s" % str(tout) 91 92 self.server = smtplib.SMTP(server, port,timeout=tout) 93 if dbg: |
|
82 self.server.set_debuglevel(1) | 94 self.server.set_debuglevel(1) |
95 |
|
83 connectiontype = xConnectionContext.getValueByName("ConnectionType") 84 if dbg: | 96 connectiontype = xConnectionContext.getValueByName("ConnectionType") 97 if dbg: |
85 print >> sys.stderr, connectiontype | 98 print >> sys.stderr, "ConnectionType: %s" % connectiontype 99 |
86 if connectiontype.upper() == 'SSL': 87 self.server.ehlo() 88 self.server.starttls() 89 self.server.ehlo() 90 91 user = xAuthenticator.getUserName().encode('ascii') 92 password = xAuthenticator.getPassword().encode('ascii') 93 if user != '': --- 115 unchanged lines hidden (view full) --- 209 try: 210 fname.encode('ascii') 211 except: 212 fname = ('utf-8','',fname.encode('utf-8')) 213 msgattachment.add_header('Content-Disposition', 'attachment', \ 214 filename=fname) 215 msg.attach(msgattachment) 216 | 100 if connectiontype.upper() == 'SSL': 101 self.server.ehlo() 102 self.server.starttls() 103 self.server.ehlo() 104 105 user = xAuthenticator.getUserName().encode('ascii') 106 password = xAuthenticator.getPassword().encode('ascii') 107 if user != '': --- 115 unchanged lines hidden (view full) --- 223 try: 224 fname.encode('ascii') 225 except: 226 fname = ('utf-8','',fname.encode('utf-8')) 227 msgattachment.add_header('Content-Disposition', 'attachment', \ 228 filename=fname) 229 msg.attach(msgattachment) 230 |
217 | |
218 uniquer = {} 219 for key in recipients: 220 uniquer[key] = True 221 if len(ccrecipients): 222 for key in ccrecipients: 223 uniquer[key] = True 224 if len(bccrecipients): 225 for key in bccrecipients: --- 109 unchanged lines hidden (view full) --- 335 print >> sys.stderr, port 336 connectiontype = xConnectionContext.getValueByName("ConnectionType") 337 if dbg: 338 print >> sys.stderr, connectiontype 339 print >> sys.stderr, "BEFORE" 340 if connectiontype.upper() == 'SSL': 341 self.server = poplib.POP3_SSL(server, port) 342 else: | 231 uniquer = {} 232 for key in recipients: 233 uniquer[key] = True 234 if len(ccrecipients): 235 for key in ccrecipients: 236 uniquer[key] = True 237 if len(bccrecipients): 238 for key in bccrecipients: --- 109 unchanged lines hidden (view full) --- 348 print >> sys.stderr, port 349 connectiontype = xConnectionContext.getValueByName("ConnectionType") 350 if dbg: 351 print >> sys.stderr, connectiontype 352 print >> sys.stderr, "BEFORE" 353 if connectiontype.upper() == 'SSL': 354 self.server = poplib.POP3_SSL(server, port) 355 else: |
343 self.server = poplib.POP3(server, port) | 356 tout = xConnectionContext.getValueByName("Timeout") 357 if dbg: 358 print >> sys.stderr, isinstance(tout,int) 359 if not isinstance(tout,int): 360 tout = _GLOBAL_DEFAULT_TIMEOUT 361 if dbg: 362 print >> sys.stderr, "Timeout: %s" % str(tout) 363 self.server = poplib.POP3(server, port, timeout=tout) |
344 print >> sys.stderr, "AFTER" 345 346 user = xAuthenticator.getUserName().encode('ascii') 347 password = xAuthenticator.getPassword().encode('ascii') 348 if dbg: 349 print >> sys.stderr, 'Logging in, username of', user 350 self.server.user(user) 351 self.server.pass_(password) --- 98 unchanged lines hidden --- | 364 print >> sys.stderr, "AFTER" 365 366 user = xAuthenticator.getUserName().encode('ascii') 367 password = xAuthenticator.getPassword().encode('ascii') 368 if dbg: 369 print >> sys.stderr, 'Logging in, username of', user 370 self.server.user(user) 371 self.server.pass_(password) --- 98 unchanged lines hidden --- |