Skip to content

Instantly share code, notes, and snippets.

@salehi
Forked from frankyxhl/zoho_send_email.py
Created September 5, 2021 07:57
Show Gist options
  • Save salehi/ada0f26fc50b209686f266cac7154cbb to your computer and use it in GitHub Desktop.
Save salehi/ada0f26fc50b209686f266cac7154cbb to your computer and use it in GitHub Desktop.

Revisions

  1. @frankyxhl frankyxhl revised this gist Dec 7, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion zoho_send_email.py
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@
    # Create message
    msg = MIMEText("Message text", 'plain', 'utf-8')
    msg['Subject'] = Header("Sent from python", 'utf-8')
    msg['From'] = formataddr((str(Header(sender_title, 'utf-8')), user))
    msg['From'] = formataddr((str(Header(sender_title, 'utf-8')), sender))
    msg['To'] = recipient

    # Create server object with SSL option
  2. @frankyxhl frankyxhl revised this gist May 12, 2018. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion zoho_send_email.py
    Original file line number Diff line number Diff line change
    @@ -4,15 +4,17 @@
    import smtplib
    from email.mime.text import MIMEText
    from email.header import Header
    from email.utils import formataddr

    # Define to/from
    sender = '[email protected]'
    sender_title = "Allan Smith"
    recipient = '[email protected]'

    # Create message
    msg = MIMEText("Message text", 'plain', 'utf-8')
    msg['Subject'] = Header("Sent from python", 'utf-8')
    msg['From'] = sender
    msg['From'] = formataddr((str(Header(sender_title, 'utf-8')), user))
    msg['To'] = recipient

    # Create server object with SSL option
  3. @frankyxhl frankyxhl revised this gist May 12, 2018. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions zoho_send_email.py
    Original file line number Diff line number Diff line change
    @@ -3,14 +3,15 @@

    import smtplib
    from email.mime.text import MIMEText
    from email.header import Header

    # Define to/from
    sender = '[email protected]'
    recipient = '[email protected]'

    # Create message
    msg = MIMEText("Message text")
    msg['Subject'] = "Sent from python"
    msg = MIMEText("Message text", 'plain', 'utf-8')
    msg['Subject'] = Header("Sent from python", 'utf-8')
    msg['From'] = sender
    msg['To'] = recipient

  4. @frankyxhl frankyxhl created this gist May 8, 2018.
    23 changes: 23 additions & 0 deletions zoho_send_email.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    # Code from best solution in page below:
    # https://help.zoho.com/portal/community/topic/zoho-mail-servers-reject-python-smtp-module-communications

    import smtplib
    from email.mime.text import MIMEText

    # Define to/from
    sender = '[email protected]'
    recipient = '[email protected]'

    # Create message
    msg = MIMEText("Message text")
    msg['Subject'] = "Sent from python"
    msg['From'] = sender
    msg['To'] = recipient

    # Create server object with SSL option
    server = smtplib.SMTP_SSL('smtp.zoho.com', 465)

    # Perform operations via server
    server.login('[email protected]', 'password')
    server.sendmail(sender, [recipient], msg.as_string())
    server.quit()