public
Description: My personal patches to http://newspipe.sourceforge.net/
Homepage: http://newspipe.sourceforge.net/
Clone URL: git://github.com/ktf/newspipe.git
Patch to get newspipe to work with GMail.
* TLS support (--smtp_tls command line option added).
* Option added to specify smtp port (--smtp_port).
* Fixes a typo which caused smtp.login() to be never called.
* Messages now come from 'sender' rather than from 'From' because gmail
  refuses to rely mail address different than your own.
Giulio Eulisse (author)
Fri May 16 05:34:56 -0700 2008
commit  5bcb599e5d8e5a59e094840bf702d5c7d1c2a0e1
tree    1c42403f1ec6e0fb09ec94354e4242c8f293207b
parent  ac2929ea52fe41f00754d51f384cd740b2646492
...
99
100
101
 
 
102
103
104
...
1100
1101
1102
1103
 
1104
1105
 
 
1106
1107
1108
...
1154
1155
1156
1157
1158
 
1159
1160
1161
1162
1163
1164
 
 
 
 
 
1165
1166
1167
...
1173
1174
1175
1176
 
1177
1178
1179
...
1193
1194
1195
 
1196
1197
 
 
 
 
 
1198
1199
1200
1201
1202
1203
1204
 
 
1205
1206
1207
...
1806
1807
1808
1809
 
1810
1811
1812
...
99
100
101
102
103
104
105
106
...
1102
1103
1104
 
1105
1106
1107
1108
1109
1110
1111
1112
...
1158
1159
1160
 
 
1161
1162
1163
1164
1165
1166
 
1167
1168
1169
1170
1171
1172
1173
1174
...
1180
1181
1182
 
1183
1184
1185
1186
...
1200
1201
1202
1203
1204
 
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
 
1216
1217
1218
1219
1220
...
1819
1820
1821
 
1822
1823
1824
1825
0
@@ -99,6 +99,8 @@ CONFIG_DEFAULTS = {
0
     'smtp_auth' : '0',
0
     'smtp_user' : '',
0
     'smtp_pass' : '',
0
+    'smtp_port' : '25',
0
+    'smtp_tls'  : 0,
0
     'from_address' : '',
0
     'send_method': 'smtp',
0
     'procmail': '',
0
@@ -1100,9 +1102,11 @@ def LeerConfig():
0
     parser.add_option("-r", "--proxy", dest="proxy", help="addess and port of the proxy server to use")
0
     parser.add_option("-a", "--threading", action="store_const", const="1", dest="threading", help="include threading headers in the emails")
0
     parser.add_option("", "--subject", dest="subject", help="add a fixed text to the subject of every message")
0
-    parser.add_option("", "--smtp_authentication", action="store_const", const="0", dest="smtp_auth", help="authenticate with SMTP server")
0
+    parser.add_option("", "--smtp_authentication", action="store_const", const="1", dest="smtp_auth", help="authenticate with SMTP server")
0
     parser.add_option("", "--smtp_auth_user", dest="smtp_user", help="SMTP username used for authentication")
0
     parser.add_option("", "--smtp_auth_pass", dest="smtp_pass", help="SMTP password used for authentication")
0
+    parser.add_option("", "--smtp_port", dest="smtp_port", help="TCP port on which the SMTP server listen")
0
+    parser.add_option("", "--smtp_tls", action="store_const", const="1", dest="smtp_tls", help="SMTP server uses TLS")
0
     parser.add_option("", "--send_method", dest="send_method", help="Method used to send the resulting emails. Possible values: SMTP, PROCMAIL, BOTH")
0
     parser.add_option("", "--procmail", dest="procmail", help="Path of the procmail script, used when SEND_METHOD=PROCMAIL or BOTH")
0
     parser.add_option("", "--reverse", action="store_const", const="1", dest="reverse", help="reverse the order of emails as they are sent")
0
@@ -1154,14 +1158,17 @@ def LeerConfig():
0
     return result
0
 # end def
0
 
0
-
0
-def EnviarEmails(msgs, method, server, auth, auth_user, auth_pass, procmail, reverse):
0
+def EnviarEmails(msgs, method, server, auth, auth_user, auth_pass, procmail, reverse, port, tls, sender):
0
     if msgs:
0
         if reverse:
0
             msgs.reverse()
0
         
0
         if method.lower() in ('smtp', 'both'):
0
-            smtp = smtplib.SMTP(server)
0
+            smtp = smtplib.SMTP(server, port)
0
+            if tls:
0
+                smtp.ehlo()
0
+                smtp.starttls()
0
+                smtp.ehlo()
0
             # authenticate with SMTP server when there's need to
0
             if auth:
0
                 smtp.login(auth_user,auth_pass);
0
@@ -1173,7 +1180,7 @@ def EnviarEmails(msgs, method, server, auth, auth_user, auth_pass, procmail, rev
0
                 if msg == None: 
0
                     continue
0
     
0
-                fromaddr = msg['From']
0
+                fromaddr = sender
0
     
0
                 r = re.compile('<(.+?)>')
0
                 toaddr = r.findall(msg['To'])
0
@@ -1193,15 +1200,21 @@ def EnviarEmails(msgs, method, server, auth, auth_user, auth_pass, procmail, rev
0
     
0
                 if count % 10 == 0:
0
                     # close the connection and reconnect every 10 messages
0
+                    smtp.rset()
0
                     smtp.quit()
0
-                    smtp = smtplib.SMTP(server)
0
+                    smtp = smtplib.SMTP(server, port)
0
+                    if tls:
0
+                        smtp.ehlo()
0
+                        smtp.starttls()
0
+                        smtp.ehlo()
0
                     # authenticate with SMTP server when there's need to
0
                     if auth:
0
                         smtp.login(auth_user,auth_pass);
0
                     # end if
0
                 # end if
0
             # end for
0
-            
0
+
0
+            smtp.rset()
0
             smtp.quit()
0
             if count != len(msgs):
0
                 note = " (" + str(len(msgs)-count) +" failed)"
0
@@ -1806,7 +1819,7 @@ def MainLoop():
0
                     # end while
0
 
0
                     try:
0
-                        EnviarEmails (emails, config['send_method'], config['smtp_server'], config['smtp_auth'] == '1',config['smtp_user'],config['smtp_pass'], config['procmail'], config['reverse'] == '1')
0
+                        EnviarEmails (emails, config['send_method'], config['smtp_server'], config['smtp_auth'] == '1',config['smtp_user'],config['smtp_pass'], config['procmail'], config['reverse'] == '1', config['smtp_port'], config['smtp_tls'], config['sender'])
0
                     except KeyboardInterrupt:
0
                         raise
0
                     except Exception, e:

Comments