Skip to content

Commit

Permalink
Merge pull request #57 from AvishkaWeebadde/avishka
Browse files Browse the repository at this point in the history
a simple mailing client with python
  • Loading branch information
AyanSaha25 authored Oct 17, 2020
2 parents c73e073 + 2c03517 commit 262f3f6
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
39 changes: 39 additions & 0 deletions mailing_client/mailing_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import smtplib

from email import encoders
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email.mime.multipart import MIMEMultipart

server = smtplib.SMTP("smtp.gmail.com", 587) #enter your smtp server here. I've used google's one.
server.ehlo()
server.starttls()

with open('password.txt', 'r') as f:
password = f.read()

server.login('[email protected]', password) #sender's email here at [email protected] and edit the password file with the sender's email's password.
msg = MIMEMultipart()
msg['from'] = 'laptop'
msg['to'] = '' #enter designated email here/ [email protected]
msg['subject'] = 'just a test'

with open('msg.txt', 'r') as f:
message = f.read()

msg.attach(MIMEText(message, 'plain'))

filename = 'wolf.jpg' #attach additional files here. I've attached a jpeg
attachment = open(filename, 'rb') #reading byte mode for images

p = MIMEBase('application', 'octet-stream')
p.set_payload(attachment.read())


encoders.encode_base64(p)

p.add_header('Content-Disposition', f'attachment; filename={filename}')
msg.attach(p)

text = msg.as_string()
server.sendmail('[email protected]', '[email protected]', text )
4 changes: 4 additions & 0 deletions mailing_client/msg.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
hello world
this is my test on a mail client made with python

jjjjjjjjjjjjjjj
1 change: 1 addition & 0 deletions mailing_client/password.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
qwer12356
Binary file added mailing_client/wolf.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 262f3f6

Please sign in to comment.