diff options
author | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2022-09-20 14:12:30 -0400 |
---|---|---|
committer | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2022-09-20 14:12:30 -0400 |
commit | 87e0e464959c026ada435ef744bcd6ca22adccb5 (patch) | |
tree | e92eca562f859eb3c2682c159923a51bb16eb784 | |
parent | 075b35bf5b62778f1a3534dba55420d3e5a4a9fc (diff) | |
download | b4-87e0e464959c026ada435ef744bcd6ca22adccb5.tar.gz |
smtp: more fully implement sendemail cmdline compatibility
Implement the sendmail cmdline compatibility similarly to how it is done
by git-send-email.
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r-- | b4/__init__.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/b4/__init__.py b/b4/__init__.py index 03f658d..415301f 100644 --- a/b4/__init__.py +++ b/b4/__init__.py @@ -2996,6 +2996,16 @@ def get_smtp(identity: Optional[str] = None, sp = shlex.shlex(server, posix=True) sp.whitespace_split = True smtp = list(sp) + if '-i' not in smtp: + smtp.append('-i') + # Do we have the envelopesender defined? + env_sender = sconfig.get('envelopesender', '') + if env_sender: + envpair = email.utils.parseaddr(env_sender) + else: + envpair = email.utils.parseaddr(fromaddr) + if envpair[1]: + smtp += ['-f', envpair[1]] return smtp, fromaddr encryption = sconfig.get('smtpencryption') @@ -3197,7 +3207,8 @@ def send_mail(smtp: Union[smtplib.SMTP, smtplib.SMTP_SSL, None], msgs: Sequence[ logger.info('Sending via "%s"', ' '.join(smtp)) for destaddrs, bdata, lsubject in tosend: logger.info(' %s', lsubject.full_subject) - ecode, out, err = _run_command(smtp, stdin=bdata) + cmdargs = list(smtp) + list(destaddrs) + ecode, out, err = _run_command(cmdargs, stdin=bdata) if ecode > 0: raise RuntimeError('Error running %s: %s' % (' '.join(smtp), err.decode())) sent += 1 |