0
我試圖使用SparkPost SMTP API無法發送郵件通過SparkPost使用Python客戶
response = spark.transmissions.send(
recipients=['[email protected]'],
text='hi',
content={
"template_id": "my-first-email",
"from":{"name": "someone", "email": "[email protected]"},
},
subject='Subject Line',
substitution_data={
"name": "Your Name"
}
)
按照documentation它應該工作來發送郵件,但我收到以下錯誤保存的模板。
Traceback (most recent call last):
File "sendmail.py", line 69, in <module>
sparkpost()
File "sendmail.py", line 65, in sparkpost
"name": "Rupesh"
File "/usr/local/lib/python2.7/dist-packages/sparkpost/transmissions.py", line 254, in send
results = self.request('POST', self.uri, data=json.dumps(payload))
File "/usr/local/lib/python2.7/dist-packages/sparkpost/base.py", line 41, in request
**kwargs)
File "/usr/local/lib/python2.7/dist-packages/sparkpost/base.py", line 16, in request
raise SparkPostAPIException(response)
sparkpost.exceptions.SparkPostAPIException: Call to https://api.sparkpost.com/api/v1/transmissions returned 422, errors:
required field is missing Code: 1400 Description: content.from is a required field
PS-一切工作正常與Sparkpost提供郵差例子。