Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Extra key-value pairs in parameters for email

def sendmail(From, To, Subject, Content, **header):
    print('From:', From)
    print('To:', To)
    print('Subject:', Subject)
    for field, value in header.items():
        print(f"X-{field}: {value}")
    print('')
    print(Content)

sendmail(
    Subject = 'self message',
    Content = 'Has some content too',
    From = 'gabor@szabgab.com',
    To = 'szabgab@gmail.com',

    mailer = "Python",
    signature = "My sig",
)

Output:

From: gabor@szabgab.com
To: szabgab@gmail.com
Subject: self message
X-mailer: Python
X-signature: My sig

Has some content too