我试图通过EmailMessage
发送一个文件,但是我得到了一个错误No such file or directory
。该文件位于上述目录中,因此
为什么我不能通过电子邮件发送文件?在
from django.core.mail import send_mail, EmailMessage
def email_file(recipient, title, email_msg, file_name):
try:
msg = EmailMessage(title, email_msg, to=recipient)
msg.attach_file(file_name)
msg.send()
except Exception as exception:
print exception.args
if __name__ == '__main__':
excel_file = '/home/geeks/test.pdf'
recipient = 'email'
email_msg = 'Please find placement report of this week'
title = 'Status Report'
email_file(recipient, title, email_msg, excel_file)
文件权限为
^{pr2}$
它本身就表明了答案。在
您的文件在指定的路径中不存在,或者没有足够的权限读取文件。在
相关问题 更多 >
编程相关推荐