i. steps to reproduce:
    - standard linux installation (tested both on CentOS and debian)
    - standard postfix installation (should apply to sendmail also)
    - send email using ubercart's UbercartMailSystem to an external address
     (i.e. address not ending in the same domain as the web server)
    - in system maillog observer error message "Could not resolve sender domain. (in reply to MAIL FROM command)"

ii. expecting that the e-mail would be sent

iii. e-mail not sent to external address

Ubercart provides its own implementation og drupal's MailSystemInterface. The main purpose of the special implementation
is to enable HTML e-mails, but drupal's default mail interface converts all html message to standard text messages.

In effect this means that Ubercarts implementation would only need to provide it's own format method. However, UC also
re-implements the interface's mail method. That's where the problem lies.

UC's mail method ends with:

    return mail(
      $message['to'],
      mime_header_encode($message['subject']),
      // Note: e-mail uses CRLF for line-endings. PHP's API requires LF
      // on Unix and CRLF on Windows. Drupal automatically guesses the
      // line-ending format appropriate for your system. If you need to
      // override this, adjust $conf['mail_line_endings'] in settings.php.
      preg_replace('@\r?\n@', $line_endings, $message['body']),
      // For headers, PHP's API suggests that we use CRLF normally,
      // but some MTAs incorrectly replace LF with CRLF. See #234403.
      implode("\n", $mimeheaders)
    );

looking at drupal's DefaultMailSystem the correct call should be:

        // On most non-Windows systems, the "-f" option to the sendmail command
        // is used to set the Return-Path. There is no space between -f and
        // the value of the return path.
        $mail_result = @mail(
          $message['to'],
          $mail_subject,
          $mail_body,
          $mail_headers,
          '-f' . $message['Return-Path']
        );
 

Note the *crucial* -f parameter

Since the mail method is where the real action takes place, and since it doesn't care if we are sending html messages,
I suggest that Ubercart's mail method should simply be:

	public function mail(array $message) {

		$mailer = drupal_mail_system('default-system','');
		return $mailer->mail($message);
	}

Using this soultion ubercart can automatically take advantage of any issues fixed in drupal's default mail handler.

skari

CommentFileSizeAuthor
#2 2175919-mail-system-inherit.patch1.76 KBlongwave
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

skari’s picture

Issue summary: View changes

minor formatting issues

longwave’s picture

Status: Active » Needs review
Issue tags: -application email
FileSize
1.76 KB

It would be even simpler to inherit from DefaultMailSystem. Can you test the attached patch?

skari’s picture

Yes,

of course a much simpler and more elegant solution.
It works.

Thx

longwave’s picture

Status: Needs review » Fixed

Committed. Thank you for looking into this issue!

This change had already been made in 8.x-4.x and does not apply to 6.x-2.x.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.