I just moved a Concrete5 website from one Ubuntu server to another, yet for some reason submitting an email form (a Form block) results in some major errors-- looking in the Concrete5 log under /dashboard/reports/logs shows an "Unable to send mail" error.

Here's how I fixed it. The problem occurs because multiple email addresses are put in the recipients field, separated by commas, which works for the Zend_Mail object's To array but not its Header->To or Recipients arrays -- commas are stripped out of those causing invalid email addresses to be entered, mucking things up later. I could have gone the route of making things ignore the Header and Recipients arrays (as they apparently were on my other server when it was working -- different Zend or Sendmail version?) but all of the code generally expects a single email address per function call despite many Concrete5 blocks using to($email) liberally with multiple comma-separated email addresses. So, the hack was to allow the to($email) to take single emails OR multiple emails:

In concrete/helpers/mail.php @Line 121, I added the explode and foreach code in case there are multiple emails in the $email string:

    public function to($email, $name = null) {
            $recipient\_array = explode(",",$email);
            foreach($recipient\_array as $recipient) {
                    $this->to\[\] = array($recipient, $name);
            }
    }

This patch has already been implemented in more-recent versions of Concrete5 such as 5.4.1.1, I just stumbled upon this during the move and made my own patch because I was running Concrete5 version 5.3.3 at the time. Yet another reason to keep your scripts updated!

Here is the same function from version 5.4.1.1 in case you want to use "official" code instead of my hack (line 154 from concrete/helpers/mail.php):

public function to($email, $name = null) {
    if (strpos($email, ',') > 0) {
        $email = explode(',', $email);
        foreach($email as $em) {
            $this->to\[\] = array($em, $name);
        }
    } else {
        $this->to\[\] = array($email, $name);
    }
}