aboutsummaryrefslogtreecommitdiffstats
path: root/pygm2n
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2014-12-25 02:45:47 +0100
committerMatěj Cepl <mcepl@cepl.eu>2014-12-25 03:11:31 +0100
commit0ac8a0944007d87cabc2d07d94bdeeb7670e7ec9 (patch)
tree1bae0a03e26aa40bdafca2eb8cf0f4a9a04adcfa /pygm2n
parent8af6ecfe31a7767f1d76f36581b01ddd26fb3220 (diff)
downloadpygn-0ac8a0944007d87cabc2d07d94bdeeb7670e7ec9.tar.gz
Simplify mail2news.sendemail to use nntplib.post()
Diffstat (limited to 'pygm2n')
-rwxr-xr-xpygm2n13
1 files changed, 8 insertions, 5 deletions
diff --git a/pygm2n b/pygm2n
index 2dcd21e..9c4e069 100755
--- a/pygm2n
+++ b/pygm2n
@@ -16,6 +16,7 @@ Gets news article and sends it via SMTP.
from __future__ import print_function
import sys
+import nntplib
import argparse
@@ -40,7 +41,8 @@ def parse_cmdline():
parser.add_argument('-p', '--password', default='',
help='password (for auth to newsserver)')
parser.add_argument('-P', '--port', default='')
- parser.add_argument('-M', '--reader', default='')
+ # WHAT IS THIS GOOD FOR?
+ # parser.add_argument('-M', '--reader', action='store_true')
parser.add_argument('-e', '--envellope', default='')
parser.add_argument('-t', '--to', dest='rcpt')
@@ -110,12 +112,13 @@ try:
open smtp connection and send e-mail
"""
- if len(m2n.headers) > 0 and len(m2n.body) > 0:
+ if len(m2n.headers) > 0 and len(m2n.message.get_payload()) > 0:
# wl.logmsg(m2n.heads_dict,wl.ACCEPT,owner)
if not opt.test:
- resp = m2n.sendemail()
- if resp:
- print(resp)
+ try:
+ resp = m2n.sendemail()
+ except nntplib.NNTPError, message:
+ print(message)
except KeyboardInterrupt:
print('Keyboard Interrupt')