是,
- 如果我在create_message函数中的属性中添加消息['from'],那么发送gmail后会显示警告(“请注意此消息 - gmail无法验证它实际上来自。
我面临的问题 上面的问题是删除消息['来自']属性,因为它会自动从Creds Config File中检索详细信息
- 。无法设置发件人的名称(“ abc name”
因此 通过我可以实现这两件事。
创建功能看起来像这样
def create_message(sender, to, cc, subject, message_text):
message = MIMEText(message_text,'html')
message['to'] = to
message['from'] = sender
message['subject'] = subject
if str(cc) !='nan':
message['cc'] = cc
pprint(message)
return {
'raw': base64.urlsafe_b64encode(
bytes(
message.as_string(),
"utf-8")).decode("utf-8")}
The problem I am facing is that
- If I add message['from'] in attribute in the create_message function then after sending Gmail shows a warning ("Be careful with this message - gmail could not verify that it actually came from .
The solution to the above problem is to remove message['from'] attribute as it automatically retrieves the details from creds config file. Once I remove the from attribute, the warning goes away.
- If I remove the message['from'] attribute, I am not able to set the Sender's Name ("ABC NAME" [email protected].
Hence mail goes like [email protected] instead of ABC Name
Looking for a way through which I can achieve both the things.
Create Function looks like this
def create_message(sender, to, cc, subject, message_text):
message = MIMEText(message_text,'html')
message['to'] = to
message['from'] = sender
message['subject'] = subject
if str(cc) !='nan':
message['cc'] = cc
pprint(message)
return {
'raw': base64.urlsafe_b64encode(
bytes(
message.as_string(),
"utf-8")).decode("utf-8")}
发布评论