Helper plugin linkback is not available or invalid.
Пример отправки e-mail сообщений с прикрепленными файлами через стандартную библиотеку smtplib
import smtplib
from os.path import basename
from email.mime.application import MIMEApplication
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.utils import COMMASPACE, formatdate
def send_mail(send_from, send_to, subject, text, files=None,
server="127.0.0.1"):
assert isinstance(send_to, list)
msg = MIMEMultipart()
msg['From'] = send_from
msg['To'] = COMMASPACE.join(send_to)
msg['Date'] = formatdate(localtime=True)
msg['Subject'] = subject
msg.attach(MIMEText(text))
for f in files or []:
with open(f, "rb") as fil:
part = MIMEApplication(
fil.read(),
Name=basename(f)
)
# After the file is closed
part['Content-Disposition'] = 'attachment; filename="%s"' % basename(f)
msg.attach(part)
smtp = smtplib.SMTP(server)
smtp.sendmail(send_from, send_to, msg.as_string())
smtp.close()
| | | 2015/10/13 09:01 | mail,
exim4,
smtp |
| | | 2016/08/17 22:51 | postfix,
mail,
pop3,
smtp,
exim4 |
| | | 2024/04/05 15:44 | python,
alembic |
| | | 2024/05/20 12:34 | languages,
python,
book,
pip,
python-setuptools,
easy install |
| | | 2024/05/26 22:49 | languages,
python,
book,
pip,
python-setuptools,
easy install |
| | | 2015/10/13 09:01 | languages,
python,
book,
pip,
python-setuptools,
easy install |
| | | 2024/05/26 22:53 | languages,
python,
book,
pip,
python-setuptools,
easy install |
| | | 2024/05/01 11:14 | languages,
python,
book,
pip,
python-setuptools,
easy install,
smtplib,
email |
| | | 2016/01/31 14:41 | languages,
python,
book,
pip,
python-setuptools,
easy install,
smtplib,
email |
| | | 2015/11/26 23:14 | service,
unix,
linux,
python,
supervisor,
initd |
| | | 2015/10/13 09:01 | server,
mail,
mta,
pop3,
smtp,
postfix,
dovecot |
| | | 2015/10/13 09:01 | mail,
exim4,
smtp |
| | | 2015/10/13 09:01 | exim4,
testing,
mail,
smtp,
pop3 |
| | | 2015/10/13 09:01 | mail,
exim4,
smtp,
exim4-config,
dpkg-reconfigure |
| | | 2015/10/13 09:01 | client,
mail,
squirrelmail |
| | | 2015/10/13 09:01 | server,
mail,
mta,
postfix,
dovecot,
config |
| | | 2015/10/13 09:01 | server,
mail,
mta,
postfix,
dovecot,
config |
| | | 2015/10/13 09:01 | server,
mail,
mta,
postfix,
dovecot,
config |
| | | 2015/10/13 09:01 | mail,
exim4,
smtp |