File: pymailgui-products/unzipped/MailConfigs/mailconfig_Gmail.py

"""
--------------------------------------------------------------------------------
THIS IS AN EXAMPLE ONLY -- emulate/replace for your email account's parameters.

See ../PyMailGUI-PP4E/mailconfig.py for the base file settings customized here.
See also textConfig.py in ../PyMailGui-PP4E for PyEdit popup window settings.

Gmail requires SSL: it supports only SSL POP, and both SSL and TLS SMTP.
Using POP to access your Gmail messages with this program requires extra steps
(alas, Gmail seems designed to steer users toward Google's own apps/sites).
In addition to using the server configurations below, you must also:

1) Enable POP for your account, and choose to keep messages accessed; see:
       https://support.google.com/mail/troubleshooter/6323470

2) Enable "Access for less secure apps"; see:
       https://support.google.com/accounts/answer/6010255 

3) Enable normal POP behavior by prepending "recent:" to your user name; see:
       https://support.google.com/mail/answer/47948

Step #3 uses Gmail's "recent" mode, which prevents emails from disappearing
from your POP list whenever they are fetched in any way.  Without "recent"
mode, you can fetch headers for more than the last 30 days' mails, but mails
are deleted from the POP inbox on any full fetch, despite user POP settings in
step #1.  This makes POP usage clumsy: the index is reloaded often due to POP
sync checks, though you can also Save and Delete mails immediately after a Load.

Further suggested reading: https://en.wikipedia.org/wiki/Gmail#Privacy.
--------------------------------------------------------------------------------
"""
import sys, os   # for platform diffs, paths

# for platform-specific choices
RunningOnMac     = sys.platform.startswith('darwin')       # all OS (X)
RunningOnWindows = sys.platform.startswith('win')          # all Windows
RunningOnLinux   = sys.platform.startswith('linux')        # all Linux


# --override PyMailGUI's mailconfig.py base-file defaults here--

# fetch (password asked in GUI)
popservername  = 'pop.gmail.com:995'            # for connection, port 110
popusername    = 'recent:sbdy716@gmail.com'     # for account login: #3 above
popusesSSL     = True                           # SSL on POP (but not TLS)

# send (password asked in GUI if needed)
smtpservername = 'smtp.gmail.com:587'           # opt port#, normal for SSL/TLS
smtpuser       = 'sbdy716@gmail.com'            # nonblank=authenticated/pswd
smtpusesTLS    = True                           # both SSL and TLS/SSL on SMTP

# this also works
# smtpservername = 'smtp.gmail.com:465'         # opt port#, normal for SSL/TLS
# smtpuser       = 'sbdy716@gmail.com'          # nonblank=authenticated/pswd
# smtpusesSSL    = True

# compose (name requires "" if '.', etc)
myaddress      = '"@#!$%" <sbdy716@gmail.com>'  # for envelope headers
mysignature    = '[Sent from my Atari ST]'      # added at end of new mail text

# list windows
listbg = 'cornsilk' #'tan'                  # back/fore color name or #RRGGBB 
listfg = 'black'
listHeight = 15                             # show this many messages initially

if RunningOnWindows:                        # account-specific fonts - monospace
    listfont = ('consolas', 12, 'bold')     # consolas isn't monospace on Linux
elif RunningOnLinux:                        # inconsolata isn't mono on Windows
    listfont = ('inconsolata', 12, 'bold')  # courier works on both, but duller
elif RunningOnMac:                          # font for Mac OS X (or courier new)
    listfont = ('monaco', 12, 'bold')       # else use main file's default 

# view windows
viewbg = '#A28264'                   # this is a dark brown; or 'black', etc.                     
viewfg = 'white'
viewheight = 20                      # show up to this many text lines initially
viewheightmin = 10                   # show at least this many lines initially
wrapsz = 80                          # wrap viewed text at/before this column

if RunningOnWindows:                        # account-specific fonts - any
    viewfont = ('arial', 13, 'normal')      # for mail main text in view/write
elif RunningOnLinux:                        # special-case fonts for Linux 
    viewfont = ('arial', 13, 'normal')      # small is better (or courier new) 
elif RunningOnMac:                          # special-case fonts for Mac OS X
    viewfont = ('menlo', 14, 'normal')      # non-bold looks better (or arial)

if RunningOnWindows:                        # view window header fonts [4.0]
    headerfont = ('consolas', 13)           # other platforms default to Tk std

# more colors: 'name', '#RRGGBB', or None=default
helpfg, helpbg = viewfg, viewbg      # server list window help bar (else blue)
partfg, partbg = 'black', 'wheat'    # view window part buttons (else grey)
ctrlfg, ctrlbg = None, 'cornsilk'    # view window action buttons (else beige)

# help bar action
showHelpAsText = False               # book's text help + source button in gui?
showHelpAsHTML = False               # book's original html help in browser?
showStandaloneHelp = True            # standalone release html help in browser?

# etc
fetchlimit = 200                     # load only up to this many latest headers
skipTextOnHtmlPart = True            # don't show selected HTML part's text too
splitOpensAll      = True            # Split opens all partt after saving them

# sent saves, used if path exists; may be account- and platform-specific;
# default=common file in program install tree: PyMailGui-PP4E/sentmail.text

#sentmailfile = None                                               # don't save
#sentmailfile = not set                                            # use default
if RunningOnWindows:
    sentmailfile = os.getenv('HOMEPATH') + r'\pmg-sentmail.txt'    # Windows
else:                                          
    sentmailfile = os.getenv('HOME') + '/pmg-sentmail.txt'         # Mac, Linux

# password files, 1 line=pswd; handy on tablets, ignored if file not present;
# as coded, located at /User/you/file on Unix, and C:\Users\you\file on Windows

#poppasswdfile  = r'..\..\_etc\pw2.txt'.replace('\\', os.sep)      # source tree
if RunningOnWindows:
    poppasswdfile = os.environ['HOMEPATH'] + r'\pmg-pw2.txt'       # Windows
else:
    poppasswdfile = os.environ['HOME'] + '/pmg-pw2.txt'            # Mac, Linux 

smtppasswdfile = poppasswdfile   # same for both fetch and send



[Home] Books Programs Blog Python Author Training Search Email ©M.Lutz