Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def sendmail_send(sender, recipient, message, config=None, section='DEFAULT'):
if config is None:
config = CONFIG
LOG.debug(
'sending message to {} via /usr/sbin/sendmail'.format(recipient))
try:
p = _subprocess.Popen(
['/usr/sbin/sendmail', recipient],
stdin=_subprocess.PIPE, stdout=_subprocess.PIPE,
stderr=_subprocess.PIPE)
stdout,stderr = p.communicate(message.as_string().encode('ascii'))
status = p.wait()
if status:
raise SendmailError(status=status, stdout=stdout, stderr=stderr)
except Exception as e:
raise SendmailError() from e
def sendmail_send(sender, recipient, message, config=None, section='DEFAULT'):
if config is None:
config = CONFIG
LOG.debug(
'sending message to {} via /usr/sbin/sendmail'.format(recipient))
try:
p = _subprocess.Popen(
['/usr/sbin/sendmail', recipient],
stdin=_subprocess.PIPE, stdout=_subprocess.PIPE,
stderr=_subprocess.PIPE)
stdout,stderr = p.communicate(message.as_string().encode('ascii'))
status = p.wait()
if status:
raise SendmailError(status=status, stdout=stdout, stderr=stderr)
except Exception as e:
raise SendmailError() from e
def __init__(self, status=None, stdout=None, stderr=None):
if status:
message = 'sendmail exited with code {}'.format(status)
else:
message = ''
super(SendmailError, self).__init__(message=message)
self.status = status
self.stdout = stdout
self.stderr = stderr