Я пытаюсь отправить необработанное электронное письмо с помощью ses и получить результат ошибки = conn.send_raw_email (msg .as_string(), AttributeError: объект «NoneType» не имеет атрибута «send_raw_email», вы можете принять, пожалуйста, смотрите Спасибо большоеamazon ses get error result = conn.send_raw_email (msg.as_string(), AttributeError: объект «NoneType» не имеет атрибута «send_raw_email»
import boto.ses
from email.mime.application import MIMEApplication
from email.mime.multipart import MIMEMultipart
def send_ses():
to_emails = ['[email protected]']
COMMASPACE = ', '
msg = MIMEMultipart()
msg['Subject'] = 'test'
msg['From'] = '[email protected]'
msg['To'] = COMMASPACE.join(to_emails)
# msg.attach(MIMEText(body))
filename = '/Users/Mac/test/products/error_csv/price_upload_error_2016-05-10 19:50:06.868506.csv'
attachment = open(filename, 'rb').read()
part = MIMEApplication(attachment)
part.add_header('Content-Disposition', 'attachment', filename='test.csv')
msg.attach(part)
try:
conn = boto.ses.connect_to_region(
'US-EAST-1',
aws_access_key_id=AWS_ACCESS_KEY,
aws_secret_access_key=AWS_SECRET_KEY
)
except Exception as e:
return e.__str__()
result = conn.send_raw_email(msg.as_string(),
source=msg['From'],
destinations=to_emails
)
return result if 'ErrorResponse' in result else ''
if __name__ == '__main__':
send_ses()