Creation repo sue RPi3
This commit is contained in:
38
Send mail/mail_attach_test.py
Normal file
38
Send mail/mail_attach_test.py
Normal file
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import smtplib
|
||||
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
from email.mime.base import MIMEBase
|
||||
from email import encoders
|
||||
|
||||
# Renseigner le compte Gmail et le destinataire
|
||||
fromaddr = "bp6412615@gmail.com"
|
||||
frompasswd = "vYqqiz-sugqo5-mywbym"
|
||||
toaddr = "bruno@clicclac.info"
|
||||
|
||||
msg = MIMEMultipart()
|
||||
msg['From'] = fromaddr
|
||||
msg['To'] = toaddr
|
||||
msg['Subject'] = "Test Python send email"
|
||||
body = 'This is an extended email test'
|
||||
msg.attach(MIMEText(body, 'plain'))
|
||||
|
||||
# Renseigner la PJ
|
||||
filename = "image.jpg"
|
||||
attachment = open("/home/pi/image.jpg", "rb")
|
||||
|
||||
part = MIMEBase('application', 'octet-stream')
|
||||
part.set_payload((attachment).read())
|
||||
encoders.encode_base64(part)
|
||||
part.add_header('Content-Disposition', "attachment; filename= %s" % filename)
|
||||
msg.attach(part)
|
||||
|
||||
server = smtplib.SMTP('smtp.gmail.com', 587)
|
||||
#server.ehlo
|
||||
server.starttls()
|
||||
server.login(fromaddr, frompasswd)
|
||||
text = msg.as_string()
|
||||
server.sendmail(fromaddr, toaddr, text)
|
||||
server.quit()
|
||||
39
Send mail/mail_extend_body.py
Normal file
39
Send mail/mail_extend_body.py
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import smtplib
|
||||
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
from email.mime.base import MIMEBase
|
||||
from email import encoders
|
||||
|
||||
# Renseigner le compte Gmail et le destinataire
|
||||
fromaddr = "bp6412615@gmail.com"
|
||||
frompasswd = "vYqqiz-sugqo5-mywbym"
|
||||
toaddr = "bruno@clicclac.info"
|
||||
|
||||
msg = MIMEMultipart()
|
||||
msg['From'] = fromaddr
|
||||
msg['To'] = toaddr
|
||||
msg['Subject'] = "Test Python send email"
|
||||
f = open("/home/pi/mail_template.txt")
|
||||
body = f.read()
|
||||
msg.attach(MIMEText(body, 'plain'))
|
||||
|
||||
# Renseigner la PJ
|
||||
filename = "image.jpg"
|
||||
attachment = open("/home/pi/image.jpg", "rb")
|
||||
|
||||
part = MIMEBase('application', 'octet-stream')
|
||||
part.set_payload((attachment).read())
|
||||
encoders.encode_base64(part)
|
||||
part.add_header('Content-Disposition', "attachment; filename= %s" % filename)
|
||||
msg.attach(part)
|
||||
|
||||
server = smtplib.SMTP('smtp.gmail.com', 587)
|
||||
#server.ehlo
|
||||
server.starttls()
|
||||
server.login(fromaddr, frompasswd)
|
||||
text = msg.as_string()
|
||||
server.sendmail(fromaddr, toaddr, text)
|
||||
server.quit()
|
||||
40
Send mail/mail_multiples_dest.py
Normal file
40
Send mail/mail_multiples_dest.py
Normal file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import smtplib
|
||||
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
from email.mime.base import MIMEBase
|
||||
from email import encoders
|
||||
|
||||
# Renseigner le compte Gmail
|
||||
fromaddr = "bp6412615@gmail.com"
|
||||
frompasswd = "vYqqiz-sugqo5-mywbym"
|
||||
# Renseigner le ou les destinataire(s)
|
||||
toaddr = "bruno@clicclac.info,bruno.pesenti@orange.fr"
|
||||
|
||||
msg = MIMEMultipart()
|
||||
msg['From'] = fromaddr
|
||||
msg['To'] = toaddr
|
||||
msg['Subject'] = "Test Python send email"
|
||||
f = open("/home/pi/mail_template.txt")
|
||||
body = f.read()
|
||||
msg.attach(MIMEText(body, 'plain'))
|
||||
|
||||
# Renseigner la PJ
|
||||
filename = "image.jpg"
|
||||
attachment = open("/home/pi/image.jpg", "rb")
|
||||
|
||||
part = MIMEBase('application', 'octet-stream')
|
||||
part.set_payload((attachment).read())
|
||||
encoders.encode_base64(part)
|
||||
part.add_header('Content-Disposition', "attachment; filename= %s" % filename)
|
||||
msg.attach(part)
|
||||
|
||||
server = smtplib.SMTP('smtp.gmail.com', 587)
|
||||
#server.ehlo
|
||||
server.starttls()
|
||||
server.login(fromaddr, frompasswd)
|
||||
text = msg.as_string()
|
||||
server.sendmail(fromaddr, toaddr, text)
|
||||
server.quit()
|
||||
9
Send mail/mailtest.php
Normal file
9
Send mail/mailtest.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
$to = "bruno@clicclac.info";
|
||||
$subject = "PHP Test mail";
|
||||
$message = "This is a test email";
|
||||
$from = "bp6412615@gmail.com";
|
||||
$headers = "From:" . $from;
|
||||
mail($to,$subject,$message,$headers);
|
||||
echo "Mail Sent.";
|
||||
?>
|
||||
25
Send mail/mailtest.py
Normal file
25
Send mail/mailtest.py
Normal file
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import smtplib
|
||||
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
|
||||
fromaddr = "bp6412615@gmail.com"
|
||||
frompasswd = "vYqqiz-sugqo5-mywbym"
|
||||
toaddr = "bruno@clicclac.info"
|
||||
|
||||
msg = MIMEMultipart()
|
||||
msg['From'] = fromaddr
|
||||
msg['To'] = toaddr
|
||||
msg['Subject'] = "Test Python send email"
|
||||
body = 'This is an extended email test'
|
||||
msg.attach(MIMEText(body, 'plain'))
|
||||
|
||||
server = smtplib.SMTP('smtp.gmail.com', 587)
|
||||
server.ehlo
|
||||
server.starttls()
|
||||
server.login(fromaddr, frompasswd)
|
||||
text = msg.as_string()
|
||||
server.sendmail(fromaddr, toaddr, text)
|
||||
server.quit()
|
||||
Reference in New Issue
Block a user