from P101_ConfigManager import ConfigManager

# IMPORTANT: MODIFY THE PATHS
file_attachments = ['files/Sample.md',                                              # Sample Text file
                    'files/Sample.jpg',                                             # Sample Image File
                    'files/Sample.pdf',                                             # Sample PDF File
                    'files/Sample.mp3'                                              # Sample Music File
                   ]

# Read SMTP and Email details from the config file
CONFIG_FILE='P000_SendEmail.config'
configManager = ConfigManager()
configManager.read(CONFIG_FILE)

SMTP_SERVER = configManager.get('SMTP', 'smtp.server')                              # SMTP Server
SMTP_PORT = configManager.get('SMTP', 'smtp.server.port')                           # SMTP Server Port
FROM_EMAIL_ID = configManager.get('SMTP', 'from.email.id')                          # FROM Email Id
FROM_EMAIL_ID_SENDER_NAME = configManager.get('SMTP', 'from.email.id.sender.name')  # From Sender Name
FROM_EMAIL_ID_PASSWORD = configManager.get('SMTP', 'from.email.id.password')        # From Email Id Password

TO_EMAIL_ID_1 = configManager.get('Emails', 'to.email.id.1')                        # First TO Email Id
TO_EMAIL_ID_1_SENDER = configManager.get('Emails', 'to.email.id.1.sender.name')     # First TO Email Sender Name
TO_EMAIL_ID_2 = configManager.get('Emails', 'to.email.id.2')                        # Seconds TO Email Id
TO_EMAIL_ID_2_SENDER = configManager.get('Emails', 'to.email.id.2.sender.name')     # Seconds TO Email Sender Name
TO_EMAIL_ID_3 = configManager.get('Emails', 'to.email.id.3')                        # Thirds TO Email Id
TO_EMAIL_ID_3_SENDER = configManager.get('Emails', 'to.email.id.3.sender.name')     # Thirds TO Email Sender Name

# Use email module to compose an email
FORMATTED_FROM_EMAIL_ID = formataddr((FROM_EMAIL_ID_SENDER_NAME, FROM_EMAIL_ID))    # Formatted FROM Email Id
FORMATTED_TO_EMAIL_IDS = [                                                          # List of Formatted TO Email Ids
# Description: Compose and Send an Email With Email Ids in CC and BCC Fields

import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.utils import formataddr

from P101_ConfigManager import ConfigManager

# Read SMTP and Email details from the config file
CONFIG_FILE = 'P000_SendEmail.config'
configManager = ConfigManager()
configManager.read(CONFIG_FILE)

SMTP_SERVER = configManager.get('SMTP', 'smtp.server')  # SMTP Server
SMTP_PORT = configManager.get('SMTP', 'smtp.server.port')  # SMTP Server Port
FROM_EMAIL_ID = configManager.get('SMTP', 'from.email.id')  # FROM Email Id
FROM_EMAIL_ID_SENDER_NAME = configManager.get(
    'SMTP', 'from.email.id.sender.name')  # From Sender Name
FROM_EMAIL_ID_PASSWORD = configManager.get(
    'SMTP', 'from.email.id.password')  # From Email Id Password

TO_EMAIL_ID_1 = configManager.get('Emails',
                                  'to.email.id.1')  # First TO Email Id
TO_EMAIL_ID_1_SENDER = configManager.get(
    'Emails', 'to.email.id.1.sender.name')  # First TO Email Sender Name
TO_EMAIL_ID_2 = configManager.get('Emails',
                                  'to.email.id.2')  # Seconds TO Email Id
TO_EMAIL_ID_2_SENDER = configManager.get(
    'Emails', 'to.email.id.2.sender.name')  # Seconds TO Email Sender Name
TO_EMAIL_ID_3 = configManager.get('Emails',
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from P101_ConfigManager import ConfigManager

# The email Module
# 1. The email module contains many classes and functions for managing email messages, including MIME and other
#    RFC 2822-based message documents.
# 2. It is specifically NOT designed to do any sending of email messages to SMTP (RFC 2821), NNTP, or other servers;
#    those are functions of modules such as smtplib and nntplib.

# Read SMTP and Email details from the config file
CONFIG_FILE='P000_SendEmail.config'
configManager = ConfigManager()
configManager.read(CONFIG_FILE)

SMTP_SERVER = configManager.get('SMTP', 'smtp.server')                          # SMTP Server
SMTP_PORT = configManager.get('SMTP', 'smtp.server.port')                       # SMTP Server Port
FROM_EMAIL_ID = configManager.get('SMTP', 'from.email.id')                      # FROM Email Id
FROM_EMAIL_ID_PASSWORD = configManager.get('SMTP', 'from.email.id.password')    # From Email Id Password

TO_EMAIL_ID = configManager.get('Emails', 'to.email.id.1')                      # TO Email Id

# Use email module to compose an email
EMAIL_SUBJECT = 'Coursera Website'                                              # Email SUBJECT
EMAIL_BODY = 'Please visit www.coursera.org.'                                   # Email BODY

message = MIMEMultipart()
message['From'] = FROM_EMAIL_ID
message['To'] = TO_EMAIL_ID
message['Subject'] = EMAIL_SUBJECT
message.attach(MIMEText(EMAIL_BODY, 'plain'))