Mail System is installed only for HTML Mail use.
When Mail System configuration Site-wide default MailSystemInterface class is set to HTMLMailSystem, the FROM field generated is not the default configuration website's one. The FROM field is set to some server configuration with a domain different from the site's one which cause mail to be considered as SPAM.

I've made a test by setting the configuration field to DefaultMailSystem : this FROM field is then correct.

HTML Mail version is the latest : 6.x-2.44

Comments

pillarsdotnet’s picture

Version: 6.x-2.11 » 6.x-2.x-dev
Assigned: Unassigned » pillarsdotnet
Status: Active » Needs work

This change comes from the code in the following issue:

#209672: Use site name in From: header for system e-mails

If you have configured your site email address in admin/settings/site-information, then that will be used as the default From address.

If you have not configured your site email, but your server has set the sendmail_from configuration option, then that will be used.

I will update the module documentation, and roll a new release shortly. There have some other minor changes not directly related to your problem.

Anonymous’s picture

The site email address is configured. When I display it using $from variable in the HTML Mail template, the displayed value is correct.
In mail content, sender field is correct (equal to site configuration) but from value not.

I'll wait for the new release.

Anonymous’s picture

I think I've found the problem ! It comes not from this module but from HTML Mail. So I will proceed to several tests before closing this ticket and open a new one in HTML Mail issues stack.

pillarsdotnet’s picture

Project: Mail System » HTML Mail

Yes, if there is a fix, it will be in HTML Mail.

pillarsdotnet’s picture

Rolling a new release now. Here's the source of a test email I received using the d6 version:

Return-Path: <user@example.com>
Delivered-To: bobvin@pillars.net
Received: (qmail 15663 invoked from network); 24 May 2011 17:56:07 -0000
Received: from unknown (HELO bowie.pillars.net) (bobvin@pillars.net@68.225.81.196)
  by mail.pillars.net with ESMTPA; 24 May 2011 17:56:07 -0000
Received: by bowie.pillars.net (sSMTP sendmail emulation); Tue, 24 May 2011 13:56:27 -0400
Date: Tue, 24 May 2011 13:56:27 -0400
To: bobvin@pillars.net
Subject: An administrator created an account for you at Example
X-PHP-Originating-Script: 1000:htmlmail.mail.inc
MIME-Version: 1.0
Content-Transfer-Encoding: 8Bit
X-Mailer: Drupal
Errors-To: user@example.com
Return-Path: user@example.com
Sender: user@example.com
From: "Example" <user@example.com>
Content-Type: multipart/alternative;
 boundary="=_2ef114980c91f9f9567443fec48d12e2"
X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.2

--=_2ef114980c91f9f9567443fec48d12e2
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=UTF-8

Bob Vincent,

A site administrator at Example has created an account for you. You may now
log in to http://d6.example.com/user using the following username and
password:

username: Bob Vincent
password: password

You may also log in by clicking on this link or copying and pasting it in
your browser:

http://d6.example.com/user/reset/4/1306259787/36c362dd28f6e76da98c03e8a22a3d11

This is a one-time login, so it can be used only once.

After logging in, you will be redirected to http://d6.example.com/user/4/edit
so you can change your password.


--  Example team

--=_2ef114980c91f9f9567443fec48d12e2
Content-Transfer-Encoding: 8bit
Content-Type: text/html; charset=UTF-8

<div class="htmlmail-body">
<pre>Bob Vincent,

A site administrator at Example has created an account for you. You may now  
log in to http://d6.example.com/user using the following username and  
password:

username: Bob Vincent
password: password

You may also log in by clicking on this link or copying and pasting it in  
your browser:

http://d6.example.com/user/reset/4/1306259787/36c362dd28f6e76da98c03e8a22a3d11

This is a one-time login, so it can be used only once.

After logging in, you will be redirected to http://d6.example.com/user/4/edit  
so you can change your password.


--  Example team</pre></div>

--=_2ef114980c91f9f9567443fec48d12e2--

pillarsdotnet’s picture

Status: Needs work » Fixed

Released HTML Mail 6.x-2.45 and Mail System 6.x-2.12.

If upgrading to these versions does not solve your problem, please re-open this issue.

Anonymous’s picture

I think the last release of HTML Mail 6.x-2.45 does not solve the problem I found :
Here is the current code (htmlmail.mail.inc, from line 189) :

    if (isset($headers['Return-Path']) && !ini_get('safe_mode')) {
      if (isset($_SERVER['WINDIR']) || strpos($_SERVER['SERVER_SOFTWARE'], 'Win32') !== FALSE) {
        // On Windows, PHP will use the value of sendmail_from for the
        // Return-Path header.
        $old_from = ini_get('sendmail_from');
        ini_set('sendmail_from', $message['Return-Path']);
      }
      else {
        // On most non-Windows systems, the "-f" option to the sendmail command
        // is used to set the Return-Path.
        $extra = '-f' . $headers['Return-Path'];
      }
    }

Using $headers['Return-Path'] is where the error is because $headers doesn't have key 'Return-Path' which is contained in $message variable. So you have to replace $headers['Return-Path'] by $message['Return-Path']. Then the correct code is :

    if (isset($message['Return-Path']) && !ini_get('safe_mode')) {
      if (isset($_SERVER['WINDIR']) || strpos($_SERVER['SERVER_SOFTWARE'], 'Win32') !== FALSE) {
        // On Windows, PHP will use the value of sendmail_from for the
        // Return-Path header.
        $old_from = ini_get('sendmail_from');
        ini_set('sendmail_from', $message['Return-Path']);
      }
      else {
        // On most non-Windows systems, the "-f" option to the sendmail command
        // is used to set the Return-Path.
        $extra = '-f' . $message['Return-Path'];
      }
    }
Anonymous’s picture

I've just tested : Released HTML Mail 6.x-2.45 and Mail System 6.x-2.12. The problem I have still occurs.
Applying #7 solve it !

Anonymous’s picture

Status: Fixed » Active

I forgot to reopen it...

pillarsdotnet’s picture

Actually, the bug is the other way around. The Return-Path is set in $headers, not in $message. From drupal_mail(), starting at line 103 of includes/mail.inc:

  if ($default_from) {
    // To prevent e-mail from looking like spam, the addresses in the Sender and
    // Return-Path headers should have a domain authorized to use the originating
    // SMTP server. Errors-To is redundant, but shouldn't hurt.
    $headers['From'] = $headers['Sender'] = $headers['Return-Path'] = $headers['Errors-To'] = $default_from;
  }

So the code in htmlmail.mail.inc should be:

    if (isset($headers['Return-Path']) && !ini_get('safe_mode')) {
      if (isset($_SERVER['WINDIR']) || strpos($_SERVER['SERVER_SOFTWARE'], 'Win32') !== FALSE) {
        // On Windows, PHP will use the value of sendmail_from for the
        // Return-Path header.
        $old_from = ini_get('sendmail_from');
        ini_set('sendmail_from', $headers['Return-Path']);
      }
      else {
        // On most non-Windows systems, the "-f" option to the sendmail command
        // is used to set the Return-Path.
        $extra = '-f' . $headers['Return-Path'];
      }
    }
pillarsdotnet’s picture

Status: Active » Fixed

Fixed in 6.x-2.46 release. Again, please re-open this issue if the fix doesn't work for you.

Anonymous’s picture

Status: Fixed » Active

This is not the same variable $headers we are talking about. In htmlmail.mail.inc the $headers variable is created by function txtHeaders : htmlmail.mail.inc line 175 (in my case the local one and not the MailMIME class one). This function create a string which then is set to $headers.

That's is the cause of this problem : trying to access a key on a string variable.

pillarsdotnet’s picture

Status: Active » Fixed

So it should be $message['headers']['Return-Path'] then. Fixed in 6.x-2.47 release.

Also renamed $headers to $txt_headers in dev but haven't pushed that bit to a release yet.

Thanks for your help; sorry it took me so long to understand.

Anonymous’s picture

Ok, it works well now ! Thank your for you celerity.

Status: Fixed » Closed (fixed)

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