私は、python EmailMultiAlternativesを介してsendgrid smtp apiからマーケティング電子メールを送信しています。特定の電子メールを配信不能としてマークするには、そこから直接バウンスを処理する方法を知りたいのですが。PythonでSendgrid smtp APIでバウンスを処理する
コードスニペットは、次のとおりです。
def send1():
text_content = 'Hi this is the text version'
connection = get_connection(host=EMAIL_HOST,
port=EMAIL_PORT,
username=EMAIL_HOST_USER,
password=EMAIL_HOST_PASSWORD,
use_tls=EMAIL_USE_TLS)
connection.open()
subject = 'Inviting {0} to join the Business Network of SMEs'.format('surya')
html_content = template.format('Surya')
from_email = '[email protected]'
to = '[email protected]'
msg = EmailMultiAlternatives(subject, text_content, from_email, [to], connection=connection)
msg.attach_alternative(html_content, "text/html")
msg.send()
connection.close()
はmsg.send()
後にここに応答を取得することが可能ですまたはいくつかの他の方法があります。