Я пробую приведенный ниже код, но он не работает и выдает эту ошибку «AttributeError: объект 'bytes' не имеет атрибута 'policy'» Может ли кто-нибудь помочь?
import smtplib
from email.mime.text import MIMEText
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(name, category, size, price, description, right_arfile, left_arfile, front_image, back_image, top_image, bottom_image, right_image, left_image):
port = 2525
smtp_server = 'smtp.mailtrap.io'
login =
password =
message = f"<h3>New Product Submission</h3><ul><li>name: {name}</li><li>category: {category}</li><li>size: {size}</li><li>price: {price}</li><li>description: {description}</li></ul>"
sender_email = 'asd@gmail.com'
receiver_email = 'asd@gmail.com'
msg = MIMEMultipart('alternative')
msg.attach(right_arfile)
msg['Subject'] = 'Product Added'
msg['From'] = sender_email
msg['To'] = receiver_email
right_arfile_file = MIMEApplication(right_arfile, 'model/vnd.usdz+xml')
msg.attach(right_arfile_file)
# Send email
with smtplib.SMTP(smtp_server, port) as server:
server.login(login, password)
server.sendmail(sender_email, receiver_email, msg.as_string())