Python

Python vous permet d'envoyer simplement des emails en SMTP grâce à une librairie native : smtplib

Voici un exemple de code que vous pouvez adapter

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
  * File Name : send.py
  * Task : send email through Tipimail
 */
 
#!/usr/bin/python
 
import smtplib
 
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
msg = MIMEMultipart('mixed')
 
msg['Subject'] = 'subject'
msg['From']    = 'from@mail.tipimail.com'
msg['To']      = 'to@mail.tpimail.com'
html = 'message au format html'
text = 'message au format texte'
 
part1 = MIMEText(text, 'plain')
part2 = MIMEText(html, 'html')
 
username = 'username'
password = 'password'
 
msg.attach(part1)
msg.attach(part2)
 
s = smtplib.SMTP('smtp.tipimail.com', 587)
s.starttls()
 
s.login(username, password)
 
 
try:
    s.sendmail(msg['From'], msg['To'], msg.as_string())
finally:
    s.quit()

Il ne vous reste plus qu'à appeler votre script

1
python send.py