Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- msg = MIMEMultipart('alternative')
- author = formataddr((str(Header(header)), sender))
- msg['From'] = author
- msg['To'] = ','.join(receiver)
- msg['Subject'] = subject
- if "reply_to" in kwargs and kwargs["reply_to"]:
- msg['Reply-to'] = kwargs["reply_to"]
- if 'Bcc' in kwargs:
- if not isinstance(kwargs['Bcc'], list):
- kwargs['Bcc'] = [kwargs['Bcc']]
- receiver = receiver + kwargs['Bcc']
- msg['Bcc'] = ','.join(kwargs['Bcc'])
- if 'Cc' in kwargs:
- if not isinstance(kwargs['Cc'], list):
- kwargs['Cc'] = [kwargs['Cc']]
- receiver = receiver + kwargs['Cc']
- msg['Cc'] = ','.join(kwargs['Cc'])
- if 'text' in kwargs:
- msg.attach(MIMEText(kwargs.get('text'), 'plain'))
- if body != []:
- if 'mime_only' in kwargs and kwargs['mime_only']:
- msg.attach(MIMEText(body))
- else:
- msg.attach(MIMEText(body, 'html'))
- if 'files' in kwargs:
- files = kwargs['files']
- for f in files:
- with open(f, "rb") as fil:
- msg.attach(MIMEApplication(
- fil.read(),
- Content_Disposition='attachment; filename="%s"' % basename(f),
- Name=basename(f)
- ))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement