Browse Source

Add argument to set the SMTP server to use

pull/7/head
juga 1 year ago
parent
commit
7632795743
4 changed files with 25 additions and 0 deletions
  1. +6
    -0
      mixnet/client/cli.py
  2. +12
    -0
      mixnet/common.py
  3. +6
    -0
      mixnet/remailer/cli.py
  4. +1
    -0
      setup.cfg

+ 6
- 0
mixnet/client/cli.py View File

@ -71,6 +71,12 @@ def create_parser():
help="Email file path to forward to remailers."
"It can also be pass via STDIN.",
)
parser.add_argument(
"-t",
"--smtp",
help="SMTP server to use to send an Email, in the form domain[:port].",
default="localhost",
)
return parser


+ 12
- 0
mixnet/common.py View File

@ -6,6 +6,9 @@ import os
import re
import smtplib
import configargparse
import urllib3
from mixnet import defaults, exceptions
logger = logging.getLogger(__name__)
@ -93,6 +96,15 @@ def create_outgoing_msg(me, to, subject, body):
def send_email(mail_str):
mail = email.message_from_string(mail_str)
# Get the parser singleton
parser = configargparse.get_argument_parser()
args = parser.parse_args()
d, p = parse_domain_port(args.smtp)
s = smtplib.SMTP("localhost")
s.send_message(mail)
s.quit()
def parse_domain_port(domain_port):
u = urllib3.util.url.parse_url(domain_port)
return (u.host, u.port or 25)

+ 6
- 0
mixnet/remailer/cli.py View File

@ -63,6 +63,12 @@ def create_parser():
help="Email file path to forward to remailers. "
"It can also be pass via STDIN.",
)
parser.add_argument(
"-t",
"--smtp",
help="SMTP server to use to send an Email, in the form domain[:port].",
default="localhost",
)
return parser


+ 1
- 0
setup.cfg View File

@ -37,6 +37,7 @@ install_requires =
colorlog >= 4.0
configargparse >= 0.13
pEp >= 2.0
urllib3 >= 1.24
# To automatically write the version from a SCM.
setup_requires = setuptools_scm


Loading…
Cancel
Save