Post by bongo » Sat Apr 28, 2012 3:48 am

Hi,

I am using two different installations with two different hosts. One of the installations is a clean install.

The mail functions on the server are working correctly. Opencart is sending out regular emails perfectly on both installations.

Both of the options "New Order Alert Mail:" and "New Account Alert Mail:" fail to work when set to "yes".

Changing from php mail() to SMTP does not work.
Setting all files to 777 does not work.
None of the available fixes for previous versions seem applicable.

I'm hoping that someone out there is familiar with this bug and knows what the cause is.

This is happening on a production site, but it is also happening on an otherwise perfect CLEAN install, leading me to believe that it is a bug with 1.5.2.1.

There are others having the same issue here: http://forum.opencart.com/viewtopic.php?t=57481

I believe that catalog\model\checkout\order.php is responsible for the new order notifications and catalog\model\account\customer.php is responsible for new account notifications.

I will keep you updated if I find a reasonable solution, otherwise I will put in a dirty hack and remain silent for ever. In the mean time any help is appreciated!

Newbie

Posts

Joined
Sat Apr 28, 2012 3:13 am

Post by Daniel » Sat Apr 28, 2012 3:56 pm

its not a bug. your host has not configured your mail function or you have put the wrong settings.

OpenCart®
Project Owner & Developer.


User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by CoronaTechniek » Sat Apr 28, 2012 4:37 pm

try this in mail.php make a backup of mail.php it works for my OC

Code: Select all

    <?php
    final class Mail {
        protected $to;
        protected $from;
        protected $sender;
        protected $subject;
        protected $text;
        protected $html;
        protected $attachments = array();
        public $protocol = 'mail';
        public $hostname;
        public $username;
        public $password;
        public $port = 25;
        public $timeout = 5;
        public $newline = "\r\n";
        public $crlf = "\r\n";
        public $verp = FALSE;
        public $parameter = '';

        public function setTo($to) {
            $this->to = $to;
        }

        public function setFrom($from) {
            $this->from = $from;
        }

        public function addheader($header, $value) {
            $this->headers[$header] = $value;
        }

        public function setSender($sender) {
            $this->sender = html_entity_decode($sender);
        }

    public function setSubject($subject) {
          $this->subject = '=?UTF-8?B?' . base64_encode($subject) . '?=';
       }

        public function setText($text) {
            $this->text = $text;
           

           
           

        }

        public function setHtml($html) {
            $this->html = $html;
        }

        public function addAttachment($file, $filename = '') {
            if (!$filename) {
                $filename = basename($file);
            }

            $this->attachments[] = array(
                'filename' => $filename,
                'file'     => $file
            );
        }

        public function send() {
            if (!$this->to) {
                exit('Error: E-Mail to required!');
            }

            if (!$this->from) {
                exit('Error: E-Mail from required!');
            }

            if (!$this->sender) {
                exit('Error: E-Mail sender required!');
            }

            if (!$this->subject) {
                exit('Error: E-Mail subject required!');
            }

            if ((!$this->text) && (!$this->html)) {
                exit('Error: E-Mail message required!');
            }

            if (is_array($this->to)) {
                $to = implode(',', $this->to);
            } else {
                $to = $this->to;
            }

            $boundary = '----=_NextPart_' . md5(time());

            $header = '';

            if ($this->protocol != 'mail') {
                $header .= 'To: ' . $to . $this->newline;
                $header .= 'Subject: ' . $this->subject . $this->newline;
            }
           
            $header .= 'Date: ' . date("D, d M Y H:i:s O") . $this->newline;
            //$header .= 'From: "' . $this->sender . '" <' . $this->from . '>' . $this->newline;
            //$header .= 'From: ' . $this->sender . '<' . $this->from . '>' . $this->newline;
            $header .= 'From: ' . '=?UTF-8?B?'.base64_encode($this->sender).'?=' . '<' . $this->from . '>' . $this->newline;
            $header .= 'Reply-To: ' . $this->sender . '<' . $this->from . '>' . $this->newline;
            $header .= 'Return-Path: ' . $this->from . $this->newline;
            $header .= 'X-Mailer: PHP/' . phpversion() . $this->newline;
            $header .= 'MIME-Version: 1.0' . $this->newline;
            $header .= 'Content-Type: multipart/mixed; boundary="' . $boundary . '"' . $this->newline;
            $header .= 'Content-Transfer-Encoding: 8bit' . $this->newline;       
            $header .= $this->newline;

            if (!$this->html) {
                $message  = '--' . $boundary . $this->newline;
                $message .= 'Content-Type: text/plain; charset="utf-8"' . $this->newline;
                $message .= 'Content-Transfer-Encoding: 8bit' . $this->newline . $this->newline;
                $message .= $this->text . $this->newline;
            } else {
                $message  = '--' . $boundary . $this->newline;
                $message .= 'Content-Type: multipart/alternative; boundary="' . $boundary . '_alt"' . $this->newline . $this->newline;
                $message .= '--' . $boundary . '_alt' . $this->newline;
                $message .= '' . $this->newline;
                $message .= '' . $this->newline;

                if ($this->text) {
                    $message .= $this->text . $this->newline;
                } else {
                    $message .= '' . $this->newline;
                }

                $message .= '--' . $boundary . '_alt' . $this->newline;
                $message .= 'Content-Type: text/html; charset="utf-8"' . $this->newline;
                $message .= 'Content-Transfer-Encoding: 8bit' . $this->newline . $this->newline;
                $message .= $this->html . $this->newline;
                $message .= '--' . $boundary . '_alt--' . $this->newline;
            }

    foreach ($this->attachments as $attachment) {
             if (file_exists($attachment['file'])) {
                $handle = fopen($attachment['file'], 'r');
                $content = fread($handle, filesize($attachment['file']));
         
                fclose($handle);
         
                $message .= '--' . $boundary . $this->newline;
                $message .= 'Content-Type: application/octetstream' . $this->newline;   
                $message .= 'Content-Transfer-Encoding: base64' . $this->newline;
                $message .= 'Content-Disposition: attachment; filename="' . basename($attachment['filename']) . '"' . $this->newline;
                $message .= 'Content-ID: <' . basename($attachment['filename']) . '>' . $this->newline . $this->newline;
                $message .= chunk_split(base64_encode($content));
             }
          }

            $message .= '--' . $boundary . '--' . $this->newline;

            if ($this->protocol == 'mail') {
                ini_set('sendmail_from', $this->from);

                if ($this->parameter) {
                    mail($to, '=?UTF-8?B?'.base64_encode($this->subject).'?=', $message, $header, $this->parameter);
                } else {
                    mail($to, '=?UTF-8?B?'.base64_encode($this->subject).'?=', $message, $header);
                }

            } elseif ($this->protocol == 'smtp') {
                $handle = fsockopen($this->hostname, $this->port, $errno, $errstr, $this->timeout);

                if (!$handle) {
                    error_log('Error: ' . $errstr . ' (' . $errno . ')');
                } else {
                    if (substr(PHP_OS, 0, 3) != 'WIN') {
                        socket_set_timeout($handle, $this->timeout, 0);
                    }

                    while ($line = fgets($handle, 515)) {
                        if (substr($line, 3, 1) == ' ') {
                            break;
                        }
                    }

                    if (substr($this->hostname, 0, 3) == 'tls') {
                        fputs($handle, 'STARTTLS' . $this->crlf);

                        while ($line = fgets($handle, 515)) {
                            $reply .= $line;

                            if (substr($line, 3, 1) == ' ') {
                                break;
                            }
                        }

                        if (substr($reply, 0, 3) != 220) {
                            error_log('Error: STARTTLS not accepted from server!');
                        }
                    }

                    if (!empty($this->username)  && !empty($this->password)) {
                        fputs($handle, 'EHLO ' . getenv('SERVER_NAME') . $this->crlf);

                        $reply = '';

                        while ($line = fgets($handle, 515)) {
                            $reply .= $line;

                            if (substr($line, 3, 1) == ' ') {
                                break;
                            }
                        }

                        if (substr($reply, 0, 3) != 250) {
                            error_log('Error: EHLO not accepted from server!');
                        }

                        fputs($handle, 'AUTH LOGIN' . $this->crlf);

                        $reply = '';

                        while ($line = fgets($handle, 515)) {
                            $reply .= $line;

                            if (substr($line, 3, 1) == ' ') {
                                break;
                            }
                        }

                        if (substr($reply, 0, 3) != 334) {
                            error_log('Error: AUTH LOGIN not accepted from server!');
                        }

                        fputs($handle, base64_encode($this->username) . $this->crlf);

                        $reply = '';

                        while ($line = fgets($handle, 515)) {
                            $reply .= $line;

                            if (substr($line, 3, 1) == ' ') {
                                break;
                            }
                        }

                        if (substr($reply, 0, 3) != 334) {
                            error_log('Error: Username not accepted from server!');
                        }

                        fputs($handle, base64_encode($this->password) . $this->crlf);

                        $reply = '';

                        while ($line = fgets($handle, 515)) {
                            $reply .= $line;

                            if (substr($line, 3, 1) == ' ') {
                                break;
                            }
                        }

                        if (substr($reply, 0, 3) != 235) {
                            error_log('Error: Password not accepted from server!');
                        }
                    } else {
                        fputs($handle, 'HELO ' . getenv('SERVER_NAME') . $this->crlf);

                        $reply = '';

                        while ($line = fgets($handle, 515)) {
                            $reply .= $line;

                            if (substr($line, 3, 1) == ' ') {
                                break;
                            }
                        }

                        if (substr($reply, 0, 3) != 250) {
                            error_log('Error: HELO not accepted from server!');
                        }
                    }

                    if ($this->verp) {
                        fputs($handle, 'MAIL FROM: <' . $this->username . '>XVERP' . $this->crlf);
                    } else {
                        fputs($handle, 'MAIL FROM: <' . $this->username . '>' . $this->crlf);
                    }

                    $reply = '';

                    while ($line = fgets($handle, 515)) {
                        $reply .= $line;

                        if (substr($line, 3, 1) == ' ') {
                            break;
                        }
                    }

                    if (substr($reply, 0, 3) != 250) {
                        error_log('Error: MAIL FROM not accepted from server!');
                    }

                    if (!is_array($this->to)) {
                        fputs($handle, 'RCPT TO: <' . $this->to . '>' . $this->crlf);

                        $reply = '';

                        while ($line = fgets($handle, 515)) {
                            $reply .= $line;

                            if (substr($line, 3, 1) == ' ') {
                                break;
                            }
                        }

                        if ((substr($reply, 0, 3) != 250) && (substr($reply, 0, 3) != 251)) {
                            error_log('Error: RCPT TO not accepted from server!');
                        }
                    } else {
                        foreach ($this->to as $recipient) {
                            fputs($handle, 'RCPT TO: <' . $recipient . '>' . $this->crlf);

                            $reply = '';

                            while ($line = fgets($handle, 515)) {
                                $reply .= $line;

                                if (substr($line, 3, 1) == ' ') {
                                    break;
                                }
                            }

                            if ((substr($reply, 0, 3) != 250) && (substr($reply, 0, 3) != 251)) {
                                error_log('Error: RCPT TO not accepted from server!');
                            }
                        }
                    }

                    fputs($handle, 'DATA' . $this->crlf);

                    $reply = '';

                    while ($line = fgets($handle, 515)) {
                        $reply .= $line;

                        if (substr($line, 3, 1) == ' ') {
                            break;
                        }
                    }

                    if (substr($reply, 0, 3) != 354) {
                        error_log('Error: DATA not accepted from server!');
                    }

                    fputs($handle, $header . $message . $this->crlf);
                    fputs($handle, '.' . $this->crlf);

                    $reply = '';

                    while ($line = fgets($handle, 515)) {
                        $reply .= $line;

                        if (substr($line, 3, 1) == ' ') {
                            break;
                        }
                    }

                    if (substr($reply, 0, 3) != 250) {
                        error_log('Error: DATA not accepted from server!');
                    }

                    fputs($handle, 'QUIT' . $this->crlf);

                    $reply = '';

                    while ($line = fgets($handle, 515)) {
                        $reply .= $line;

                        if (substr($line, 3, 1) == ' ') {
                            break;
                        }
                    }

                    if (substr($reply, 0, 3) != 221) {
                        error_log('Error: QUIT not accepted from server!');
                    }

                    fclose($handle);
                }
            }
        }
    }
    ?>

http://www.koienvijvercentrum.nl Alles voor Koi en Vijver Opencart 2.3.0.2


User avatar
Active Member

Posts

Joined
Sat Dec 17, 2011 4:25 am
Location - Groningen

Post by bongo » Sat Apr 28, 2012 7:17 pm

Hi,

@Corona Techniek,

Thanks for the advice - I have tried to use the file you provided however, it results in multiple "headers already sent"'s.

Upon closer inspection, it looks like the new mail.php handles headers in a different way and declares a few header related things that are not present in the original. Is there any way you can tell me specifically what the fix is?

______________________________________________

@Daniel - if it's not a bug, then can you explain what is happening? I have seen multiple reports of this same issue with no solution as of yet. There is a similar issue that relates to the way the mail function is configured on the server, but this is a different issue. This issue relates specifically to the new order and new account alert notifications and nothing else.

I have tested it with the php mail() and SMTP functions with the same result. The system is sending all other mail correctly, including OC mailing lists, welcome messages, etc. In addition, this has been attempted with two different hosts. These three combined troubleshooting steps pretty much rule out an error with the server's mail functions in my opinion, or am I missing something?

Regarding settings - the only setting that is specific to this function is "Send alert (yes) (no)"? If I have missed something really simple then I would really like to know - it would save me having to debugger this site.

I have read through the opencart manuals and combed the web for bug reports, troubleshooting information and the like. I have watched the PHP error logs on both servers to no avail. The error log is empty when this error occurs.

Based on this experience, I have reached the conclusion that there is a bug in 1.5 / 1.5.2.1 relating to the way the admin alert function behaves on certain servers. If this is an incorrect conclusion then I would like it to be corrected.

Newbie

Posts

Joined
Sat Apr 28, 2012 3:13 am

Post by CoronaTechniek » Sat Apr 28, 2012 10:22 pm

i dont now i have search the Internet for a solution and it works for me

http://www.koienvijvercentrum.nl Alles voor Koi en Vijver Opencart 2.3.0.2


User avatar
Active Member

Posts

Joined
Sat Dec 17, 2011 4:25 am
Location - Groningen

Post by OC2PS » Wed May 09, 2012 11:17 pm

bongo wrote:New order alert not working
bongo wrote:I have tested it with the php mail() and SMTP functions with the same result. The system is sending all other mail correctly, including OC mailing lists, welcome messages, etc.
Same problem.
1.5.2.1

OC2PS
OC 3.0.3.7, vQmod 2.6.2, Journal3 theme
Arcfesték, Csillámtetoválás, Henna
Image
Check out: All my extensions | My FREE extensions


User avatar
Active Member

Posts

Joined
Wed Jul 22, 2009 4:15 am
Location - Hungary

Post by Basikboy » Mon May 21, 2012 1:12 am

OC2PS wrote:
bongo wrote:New order alert not working
bongo wrote:I have tested it with the php mail() and SMTP functions with the same result. The system is sending all other mail correctly, including OC mailing lists, welcome messages, etc.
Same problem.
1.5.2.1
Same here and NOTHING is being done!

New member

Posts

Joined
Sun Mar 18, 2012 12:21 am

Post by overtonis » Tue Aug 07, 2012 11:00 am

We are having the same issue. We are running two different versions of open cart. On version (opencart_v1.5.2.1) emails are being sent to customers. On version (opencart_v1.5.3) emails are not being sent to customers after they make purchase and complete shipment. We are using same hosting service for both websites. Any fixes yet?

New member

Posts

Joined
Tue Apr 24, 2012 9:07 am

Post by cwswebdesign » Mon Aug 13, 2012 6:44 am

Post your settings so that we can help you debug. We don't need your password of course, but try SMTP as the protocol and port 25 or 26.

DL

This account is inactive. Look for us under the name 'EvolveWebHosting' and contact us under that username.

Thanks!


User avatar
Active Member

Posts

Joined
Sun Dec 11, 2011 12:26 am
Location - USA
Who is online

Users browsing this forum: No registered users and 45 guests