Jump to content
Psytanium

Order mails rejected by Gmail

Recommended Posts

Hi,

Users with gmail address or using gsuite app, are not receiving Order Process emails, I talked with my host provider, he found in the log the following :

20181218 14:39:17.027 core sid="ZN5Bgzz2hZVaG" id="ZN5Bgzz2hZVaGZN5Bgvnt9" ip="132.148.68.109" action="DROP" reason="BAD-SUB" mailfrom="user@server.domain.com" fromdomain="server.domain.com" recipient_list="myemail@gmail.com" todomain="gmail.com" subject="Order Process"|

Only Gmail is rejecting the mails.

Any idea ?

I tried to change the subject from Order to Process, and tried to use regular mail and smtp engine.

and in admin/include/classes/email.php i changed to this :

return mail($to, $subject, $this->output, 'From: '.$from.$this->lf.implode($this->lf, $this->headers).$this->lf.implode($this->lf, $xtra_headers));

Also I tried to add a return path in tep_mail function in generals.php to:

$message = new email(array('X-Mailer: osCommerce System Mailer','Return-Path: <' . STORE_OWNER_EMAIL_ADDRESS . '>'));

But all without success

Anyone know what is

reason="BAD-SUB"
Edited by Psytanium

Share this post


Link to post
Share on other sites
4 hours ago, Dan Cole said:

What does the email header actually look like?

Dan

I added another email address (me@mydomain.com) so i can receive the email and check the header :

Return-Path: <user@server.domain.com>
Delivered-To: me@mydomain.com
Received: from server.domain.com
	by server.domain.com with LMTP id KEwNFUnsGVyjDAAAAm/+cA
	for <me@mydomain.com>; Wed, 19 Dec 2018 08:59:21 +0200
Return-path: <user@server.domain.com>
Envelope-to: me@mydomain.com
Delivery-date: Wed, 19 Dec 2018 08:59:21 +0200
Received: from user by server.domain.com with local (Exim 4.91)
	(envelope-from <user@server.domain.com>)
	id 1gZVpB-0000z5-6b; Wed, 19 Dec 2018 08:59:21 +0200
To: sales@gmail.com,me@mydomain.com
Subject: Order Process
X-PHP-Script: www.domain.com/checkout_process.php for 178.135.82.78
X-PHP-Originating-Script: 556:email.php
From: "Wood and Gas" <sales@gmail.com>
MIME-Version: 1.0
X-Mailer: osCommerce System Mailer
Content-Type: multipart/alternative;
	boundary="=_b4318a54836abb9b2900e16846972d19"
Message-Id: <E1gZVpB-0000z5-6b@server.domain.com>
Date: Wed, 19 Dec 2018 08:59:21 +0200

 

and this the the tep mail function

function tep_mail($to_name, $to_email_address, $email_subject, $email_text, $from_email_name, $from_email_address) {
    if (SEND_EMAILS != 'true') return false;

    // Instantiate a new mail object
    $message = new email(array('X-Mailer: osCommerce System Mailer','Return-Path: <' . STORE_OWNER_EMAIL_ADDRESS . '>'));

    // Build the text version
    $text = strip_tags($email_text);
    if (EMAIL_USE_HTML == 'true') {
      $message->add_html($email_text, $text);
    } else {
      $message->add_text($text);
    }

    // Send message
    $message->build_message();
    $message->send($to_name, $to_email_address, $from_email_name, $from_email_address, $email_subject);
  }

 

Share this post


Link to post
Share on other sites

I tried to change the tep mail function to this

$message->build_message();
    $message->send($to_name, $to_email_address, $from_email_name, $from_email_address, $email_subject,'Return-Path: <' . $from_email_address . '>');

Still the return path didn't change and emails not received

Share this post


Link to post
Share on other sites

I'm not going to be around most of today or probably tomorrow so maybe someone else will jump in.  I do wonder however if can you get your hands on the header from one of the emails that is being rejected rather then your test email so you can compare the two and we're looking at one of the actual emails being rejected.  I'm wondering if they are the same?   I would also expect to see  'X-Mailer: osCommerce System Mailer' in the header but it is not so I don't think your using the usual email routine.  That would also explain why your not able to change the return path.

Dan

Share this post


Link to post
Share on other sites
6 minutes ago, Psytanium said:

i think the problem is Return-Path, any idea why I can't set Return-Path from tep_mail function ? 

Are you sure you're using that function?  Can you redefine the subject and see if you can change it?

Dan

Share this post


Link to post
Share on other sites

To make sure im using the fucntion tep_mail, I changed the subject to test like this :

$message->send($to_name, $to_email_address, $from_email_name, $from_email_address, 'test','Return-Path: me@gmail.com');

I received email with subject 'Test' but still the Return-Path is  Return-Path: <user@server.domain.com>

it seems I can't overwrite the Return-Path for some reason, most probably this is why Gmail reject my emails.

Share this post


Link to post
Share on other sites

It could be that it is defined by your host.   I know when I had issues it was because neither the host or osC was setting it.  I set it and bingo -- my emails started to get through.

Maybe you want to see what your hosts support has to say and whether it can be changed to suit your needs.

Dan

Share this post


Link to post
Share on other sites

Only inspected the class function 'send' (admin/includes/classes/email.php).
Your problem exists in the following code:
 

      if (is_string($headers)) {
        $headers = explode($this->lf, trim($headers));
      }

      for ($i=0; $i<count($headers); $i++) {
        if (is_array($headers[$i])) {
          for ($j=0; $j<count($headers[$i]); $j++) {
            if ($headers[$i][$j] != '') {
              $xtra_headers[] = $headers[$i][$j];
            }
          }
        }

        if ($headers[$i] != '') {
          $xtra_headers[] = $headers[$i];
        }
      }

      if (!isset($xtra_headers)) {
        $xtra_headers = array();
      }

      $headers = array_merge($this->headers, array('From: ' . $from), $headers, $xtra_headers);


 completely untested:
 

      if (is_string($headers)) {
        $headers = explode($this->lf, trim($headers));
		print_r($headers);
		die();//stop processing the script
      }

My gut is saying:
 

'Return-Path: me@gmail.com'

does not or cannot work for the reason it is not recognized as an array.
So i just assume something like:
 

	$myReturnPath = array('Return-path' => 'me@me.com');

But i am not 100% sure (even that i am aware i should).
I am not an email expert. 

Share this post


Link to post
Share on other sites

Perhaps leave it as you have now and check in the admin:
https://yourdomain.com/admin/configuration.php?gID=12&cID=148
Do you have set that email-option as LF or CRLF ?
If you set it as CLRF switch to LF and try again.
As your "Return-Path" inside the send method is processed as a string.

Be aware, it is only suggestive resource checking.

Share this post


Link to post
Share on other sites

I changed the Subject from "Order Process" to "Company Name Order Process" in addition to adding -treturn_email as a parameter.

This is how it worked, now Gmail accept order emails.

Edited by Psytanium

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×