họ có thể gửi các URL khác nhau để mã Python khác nhau, chèn biến Python vào các mẫu HTML, và cung cấp hỗ trợ quan trọng trong cả hai đối tượng Python sự bền bỉ vào cơ sở dữ liệu và cũng có thể trong việc để được truy cập từ các trang web cả hai thông qua người dùng phải đối mặt với CRUD | CHAPTER 13 SMTP else print Message successfully sent to d recipient s len toaddrs If you run this program and give it a server that understands TLS the output will look like this . localhost jgoerzen@ jgoerzen@ Negotiating TLS. Using TLS connection. Message successfully sent to 1 recipient s Notice that the call to sendmail in these last few listings is the same regardless of whether TLS is used. Once TLS is started the system hides that layer of complexity from you so you do not need to worry about it. Please note that this TLS example is not fully secure because it does not perform certificate validation again see Chapter 6 for details. Authenticated SMTP Finally we reach the topic of Authenticated SMTP where your ISP university or company e-mail server needs you to log in with a username and password to prove that you are not a spammer before they allow you to send e-mail. For maximum security TLS should be used in conjunction with authentication otherwise your password and username for that matter will be visible to anyone observing the connection. The proper way to do this is to establish the TLS connection first and then send your authentication information only over the encrypted communications channel. But using authentication itself is simple smtplib provides a login function that takes a username and a password. Listing 13-6 shows an example. To avoid repeating code already shown in previous listings this listing does not take the advice of the previous paragraph and sends the username and password over an un-authenticated connection that will send them in the clear. Listing 13-6. Authenticating over SMTP usr bin env python SMTP transmission with authentication - Chapter 13 - import sys smtplib socket from getpass import getpass if len 4 print Syntax s server fromaddr toaddr toaddr. 0 2 server fromaddr toaddrs 1 2 3 message To s From s Subject Test Message from .