MyBB Community Forums
[Rejected] SMTP email using 'html' format with Amazon SES - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Development (https://community.mybb.com/forum-161.html)
+--- Forum: MyBB 1.8 Development (https://community.mybb.com/forum-165.html)
+---- Forum: 1.8 Bugs and Issues (https://community.mybb.com/forum-157.html)
+----- Forum: Rejected (https://community.mybb.com/forum-184.html)
+----- Thread: [Rejected] SMTP email using 'html' format with Amazon SES (/thread-210909.html)



SMTP email using 'html' format with Amazon SES - Byte - 2017-06-06

I ran into this issue using the following:
  • Amazon SES SMTP (port 587 with TLS)
  • MyBB 1.8.11
  • Gmail as the receiving email user
Basically, I use the MyBB function my_mail to send mail (from inc/functions.php).

Example:
<?php
  define('IN_MYBB', 1);
  require "../global.php";
  require_once MYBB_ROOT."inc/functions.php";

  $user_email = "[email protected]";
  $from_email = "[email protected]";
  $email_message = "THIS IS A TEXT MESSAGE";

  $email_message = nl2br($email_message);
  $email_message = wordwrap($email_message, 70);
  $email_subject = "Testing email for new thing";
  
  //Send using MyBB mail
  my_mail($user_email, $email_subject, $email_message, $from_email, "", "", false, "html");
?>

However, this would not work with Amazon SES SMTP. I tested various other SMTP providers which worked fine (SendGrid, Mailgun, etc).

Now changing the format from 'html' to 'text' or 'both' made it work fine.
I did some digging and discovered MyBB doesn't actually use 'html' format anywhere, only 'text' or 'both'.

I managed to fix this issue by commenting out the following line in: inc/class_mailhandler.php
https://github.com/mybb/mybb/blob/52dde2dd81df0a057cc1575a1632f915db301f55/inc/class_mailhandler.php#L302

$this->headers .= "Content-Transfer-Encoding: 8bit{$this->delimiter}{$this->delimiter}";


I'm not sure if this is a MyBB bug or oddity with Amazon SES SMTP.
Just posting here in case anyone else ever runs into this issue.


RE: SMTP email using 'html' format with Amazon SES - Byte - 2018-01-02

I found another Amazon SES issue.
Amazon SES doesn't allow a custom Return-Path header field to be set.
If it is, it should ignore the field but this was causing my emails to not send at all.

Fixed it by commenting out a line in /inc/class_mailhandler.php (in function set_common_headers()):

https://github.com/mybb/mybb/blob/52dde2dd81df0a057cc1575a1632f915db301f55/inc/class_mailhandler.php#L319

 $this->headers .= "Return-Path: {$this->return_email}{$this->delimiter}";