我在Amazon SES上遇到一些奇怪的行为。我有一个使用SES发送html电子邮件的webapp,最近我注意到收到电子邮件后无法加载某些图像。
图像存储在S3中。
检查后,我注意到在某些情况下图像的URL已被修改。以该示例为例:图像的URL为http://example.com/image_name.png,在发送电子邮件后,图像的URL为http://example.com/image_name..png(注意扩展名前的双点)。
如果我向gmail和hotmail发送相同的电子邮件,则会遇到此问题,但是图像不同。 Gmail将双点放在image_2.png中,hotmail将其放在image_1.png中。
我正在使用Codeigniter电子邮件类通过SMTP发送电子邮件。
要使CI的电子邮件类别与Amazon SES一起使用,需要将换行符设置为\r\n
,如上面的注释所述。参见this question和答案。
当我们使用CodeIgnitor Amazon SES库时,此问题已解决:https://github.com/joelcox/codeigniter-amazon-ses
添加'crlf' => "\r\n"
通过以下配置解决了该问题:
/aaplication/config/email.php
<?php
$config['protocol'] = 'smtp';
$config['mail_smtp_secure'] = 'TLS';
$config['smtp_host'] = 'ssl://email-smtp.us-west-2.amazonaws.com';
$config['smtp_port'] = 465;
$config['smtp_user'] = 'user';
$config['smtp_pass'] = 'password';
$config['charset'] = 'UTF-8';
$config['mailtype'] = 'html';
$config['newline'] = "\r\n";
$config['crlf'] = "\r\n";
$config['wordwrap'] = TRUE;
$config['smtp_timeout'] = '20';
$config['bcc_batch_mode'] = TRUE;
?>