-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from AvishkaWeebadde/avishka
a simple mailing client with python
- Loading branch information
Showing
4 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
qwer12356 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.