[sylpheed:36803] using a python program to send e-mail with sylpheed

Ranjan Maitra maitra at email.com
Sun Apr 28 08:43:52 JST 2019


I am trying to figure out how to use sylpheed with sending e-mail in python (which is the only way that I can send e-mail from work).

I have the following python script (which is deliberately simple at this stage for me to simply understand what to do).


import smtplib
import email.utils
from email.mime.text import MIMEText
import getpass

# Prompt the user for connection info
to_email = input('Recipient: ')
servername = input('Mail server name: ')
serverport = input('Server port: ')
if serverport:
    serverport = int(serverport)
    serverport = 25
use_tls = input('Use TLS? (yes/no): ').lower()
username = input('Mail username: ')
password = getpass.getpass("%s's password: " % username)

# Create the message
msg = MIMEText('Test message from PyMOTW.')
msg['To'] = email.utils.formataddr(('Recipient', to_email))
msg['From'] = email.utils.formataddr(('Author', username))
msg['Subject'] = 'Test from PyMOTW'

if use_tls == 'yes':
    print('starting with a secure connection')
    server = smtplib.SMTP_SSL(servername, serverport)
    print('starting with an insecure connection')
    server = smtplib.SMTP(servername, serverport)

    # identify ourselves, prompting server for supported features

    # If we can encrypt this session, do it
    if server.has_extn('STARTTLS'):
        print('(starting TLS)')
        server.ehlo()  # reidentify ourselves over TLS connection
        print('(no STARTTLS)')

    if server.has_extn('AUTH'):
        print('(logging in)')
        server.login(username, password)
        print('(no AUTH)')


I can get it to work with my mail server, etc from the command line when I send the e-mail in the following way (note that the program is called mailsend.py and is an executable).


Then, I am asked the following:
Recipient e-mail
Server address
Whether TLS or not
Sender e-mail
Sender password

to which stdin output is required and upon correct submission, the e-mail is successfully sent.

My question is how do I get the sylpheed mailer to submit these stdin output so that the script can take over from here and deliver.

I am happy to provide more information.

Many thanks in advance for any help, and I am sorry if this is a trivial question. I am not very familiar with the sending side of things and I still want to be able to use sylpheed.

Best wishes,

More information about the Sylpheed mailing list