Emails Not Sending

Ask the community for help and support.
Post Reply
WebCreator99
Posts: 2
Joined: Wed Jan 20, 2021 4:54 pm
Has thanked: 1 time

Emails Not Sending

Post by WebCreator99 »

Hi,
I just installed Phoenix Cart, and so far I think it is one of the best eCommerce platforms I have seen so far. Unfortunately, I am having one issue with my new store. Whenever a customer makes an order, or fills out the contact form, I (as the store owner) do not get an email notification of this. My hosting provider uses a Linux server and my site is currently on a subdomain without ssl/tls (https://). Attached is the server info document from the dashboard. Can you please let me know why I am not receiving email notifications from my store?
Thanks,
T




[oscommerce]
version = 1.0.7.13

[system]
date = 2021-01-19 17:25:15 -0500 EST
os = Linux
kernel =
uptime =
http_server = Apache

[mysql]
version = 5.6.48-88.0
date = 2021-01-19 17:27:08

[php]
version = 7.4.8
zend = 3.4.0
sapi = apache2handler
int_size = 8
open_basedir = 0
memory_limit = 128M
error_reporting = 32767
display_errors = 0
allow_url_fopen = 0
allow_url_include = 0
file_uploads = 1
upload_max_filesize = 10M
post_max_size = 20M
disable_functions = exec,system,passthru,shell_exec,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,dl,popen,popen,pcntl_exec,socket_accept,socket_bind,socket_clear_error,socket_close,socket_connect,socket_create_listen,socket_create_pair,socket_create,socket_get_option,socket_getpeername,socket_getsockname,socket_last_error,socket_listen,socket_read,socket_recv,socket_recvfrom,socket_select,socket_send,socket_sendto,socket_set_block,socket_set_nonblock,socket_set_option,socket_shutdown,socket_strerror,socket_write,stream_socket_server,pfsockopen,disk_total_space,disk_free_space,chown,diskfreespace,getrusage,get_current_user,set_time_limit,dl,leak,listen,chgrp,link,symlink,dlopen,proc_nice,proc_get_stats,proc_terminate,shell_exec,sh2_exec,posix_getpwuid,posix_getgrgid,posix_kill,ini_restore,mkfifo,dbmopen,dbase_open,filepro,filepro_rowcount,posix_mkfifo,_xyec,mainwork,get_num_redirects,putenv,geoip_open,sleep,imap_open
disable_classes =
enable_dl = 0
filter.default = unsafe_raw
zend.ze1_compatibility_mode = 0
unicode.semantics = 0
zend_thread_safty = 0
extensions = Core,date,libxml,openssl,pcre,sqlite3,zlib,bcmath,calendar,ctype,curl,dom,hash,fileinfo,filter,ftp,gd,gettext,gmp,SPL,iconv,intl,json,mbstring,session,standard,mysqlnd,mysqli,PDO,pdo_mysql,pdo_sqlite,Phar,Reflection,mysql,SimpleXML,soap,exif,tokenizer,xml,xmlreader,xmlrpc,xmlwriter,xsl,zip,apache2handler,ionCube Loader
heatherbell
VIP Member
VIP Member
Posts: 1996
Joined: Mon Oct 07, 2019 4:39 am
Has thanked: 26 times
Been thanked: 175 times

Re: Emails Not Sending

Post by heatherbell »

WebCreator99 wrote: Wed Jan 20, 2021 5:20 pmCan you please let me know why I am not receiving email notifications from my store?
Some hosts will not send the email if the email address is not, for example, something@example.com, where example.com is your domain name.
Contact your host to find out why emails are not being received.
ecartz
Lead Developer
Lead Developer
Posts: 2637
Joined: Tue Nov 05, 2019 6:02 pm
Has thanked: 4 times
Been thanked: 181 times

Re: Emails Not Sending

Post by ecartz »

Is it only this notification? Or are you also not getting the other emails like registration and order confirmation? Can you email yourself from admin?

If it is only the Contact Us form and everything else is working, then you can use this SQL:

Code: Select all

INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ('E-Mail From', 'EMAIL_FROM', 'root@localhost', 'All e-mails will be sent from this address', 12, 6, NOW());
After running it (in phpMyAdmin or similar), you would need to go admin > Configuration > E-Mail Options to set the email address to one that will work. I.e. the same one as the store owner email address.

If nothing is working then you need more help from your host. Or if they won't/can't help, to get a better host. There is an App that uses PHPMailer instead of the standard PHP mail sending that you could try in that circumstance. But no one has uploaded an update for Phoenix. It remains more reliable to simply pick a host that already supports emailing from PHP.
WebCreator99
Posts: 2
Joined: Wed Jan 20, 2021 4:54 pm
Has thanked: 1 time

Re: Emails Not Sending

Post by WebCreator99 »

Hi,
Thanks for the quick responses. No emails are coming from the site at all. I tried sending myself an email from the site (Tools --> Send Email) and I never received it. I did look at my hosting provider, and I found "PHP mail is severely restricted" & "If you want to send email from your website, the easiest option is to use an external SMTP service. Most applications offer a setting or plugin to send email with SMTP." I did notice a SMTP option in Configuration --> E-Mail Options, but I did not find a way to set it up. Is this even possible in Phoenix or will I have to find a new shopping cart/hosting provider?
Thanks again,
T
ecartz
Lead Developer
Lead Developer
Posts: 2637
Joined: Tue Nov 05, 2019 6:02 pm
Has thanked: 4 times
Been thanked: 181 times

Re: Emails Not Sending

Post by ecartz »

WebCreator99 wrote: Wed Jan 20, 2021 11:21 pm "PHP mail is severely restricted" & "If you want to send email from your website, the easiest option is to use an external SMTP service. Most applications offer a setting or plugin to send email with SMTP." I did notice a SMTP option in Configuration --> E-Mail Options, but I did not find a way to set it up. Is this even possible in Phoenix or will I have to find a new shopping cart/hosting provider?
The SMTP in E-Mail Options is something the host would set up, usually on Windows servers.
ecartz wrote: Wed Jan 20, 2021 11:03 pm There is an App that uses PHPMailer instead of the standard PHP mail sending that you could try in that circumstance. But no one has uploaded an update for Phoenix. It remains more reliable to simply pick a host that already supports emailing from PHP.
They mean the PHPMailer (or similar) solution. But it would probably be easier/cheaper to switch hosts. Because hosts can set this up without that. Installing the PHPMailer solution currently requires you to manually adapt the existing App. And of course, once you have it installed, you still need to configure the thing. If you want to try it, I can find the App and extra file that you need to add. But I know nothing about PHPMailer and would be no help in configuring it.

What it really needs is someone to pay one of the certified developers to adopt and update the App. But as I said, people who need that help often find it easier/cheaper to just switch hosts. Two of the certified developers are also hosting providers.
Skalia
Posts: 2
Joined: Thu Mar 04, 2021 1:17 pm

Re: Emails Not Sending

Post by Skalia »

Since Phoenix ver. 1.0.5.0 these files responsible for sending emails have not been included in the package, any more:

includes/class/email.php
includes/class/mime.php
admin/includes/class/email.php
admin/includes/class/mime.php

1. Is it intentionally, or are they not needed any more? I think they are needed.
2. While installing PHPMailer should I create those files by myself?
3. Should l create more files, besides those crated by PHPMailer?
4. Can anyone do a short instruction: How to install PHPMailer, create new files, modify existing files, etc. for new Phoenix versions (1.07.18, 1.0.8)? Thanks!
ecartz
Lead Developer
Lead Developer
Posts: 2637
Joined: Tue Nov 05, 2019 6:02 pm
Has thanked: 4 times
Been thanked: 181 times

Re: Emails Not Sending

Post by ecartz »

Skalia wrote: Tue Mar 30, 2021 12:55 pm 1. Is it intentionally, or are they not needed any more? I think they are needed.
Those four files have been replaced by two files under includes/system/versioned

If using PHPMailer, I think that you need to provide an email.php file in includes/system/override/ with the same interface as the system version currently exposes.

That file might be

Code: Select all

  require_once DIR_FS_CATALOG . 'includes/apps/PHPMailer/PHPMailerAutoload.php';

  class email {

    private $lf, $mailer;
    private $debug = 0;
    private $debug_output = 'error_log';

    const LINEFEEDS = ["\r\n", "\n", "\r"];
    
    public function __construct($headers = '') {
      $this->mailer = new PHPMailer();

      $this->mailer->XMailer = 'CE-PhoenixCart ' . Versions::get('Phoenix');
      $this->mailer->SMTPDebug = $this->debug;
      $this->mailer->Debugoutput = $this->debug_output;
      $this->mailer->CharSet = CHARSET;
      $this->mailer->WordWrap = 998;

      if (EMAIL_TRANSPORT == 'smtp' || EMAIL_TRANSPORT == 'gmail') {
        $this->mailer->IsSMTP();

        $this->mailer->Port = EMAIL_SMTP_PORT;
        if (EMAIL_SMTP_SECURE !== 'no') {
          $this->mailer->SMTPSecure = EMAIL_SMTP_SECURE;
        }

        $this->mailer->Host = EMAIL_SMTP_HOSTS;
        $this->mailer->SMTPAuth = EMAIL_SMTP_AUTHENTICATION;

        $this->mailer->Username = EMAIL_SMTP_USER;
        $this->mailer->Password = EMAIL_SMTP_PASSWORD;

      } else {
        $this->mailer->isSendmail();
      }

      if (EMAIL_LINEFEED == 'CRLF') {
        $this->lf = "\r\n";
      } else {
        $this->lf = "\n";
      }
    }

    public function add_text($text = '') {
      $this->mailer->IsHTML(false);
      $this->mailer->Body = str_replace(static::LINEFEEDS, $this->lf, $text);
    }

    public function add_html($html, $text = NULL, $images_dir = NULL) {
      $this->mailer->IsHTML(true);
      
      $this->mailer->Body = str_replace(static::LINEFEEDS, '<br />', $html);
      $this->mailer->AltBody = str_replace(static::LINEFEEDS, $this->lf, $text);

      if (isset($images_dir)) {
        $this->mailer->Body = $this->mailer->msgHTML($this->mailer->Body, $images_dir);
      }
    }

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

    function add_attachment($path, $name = '', $encoding = 'base64', $type = '', $disposition = 'attachment') {
      $this->mailer->AddAttachment($path, $name, $encoding, $type, $disposition);
    }

    public function build_message() {
      // do nothing; needed for compatibility
    }

    public function send($to_name, $to_addr, $from_name, $from_addr, $subject = '') {
      // No need to check for "\r\n" separately as will match the other two
      foreach (["\n", "\r"] as $line_ending) {
        foreach ([$to_name, $to_addr, $subject, $from_name, $from_addr] as $header_value) {
          if (false !== strstr($header_value, $line_ending)) {
            return false;
          }
        }
      }

      $this->mailer->From = $from_addr;
      $this->mailer->FromName = $from_name;
      $this->mailer->AddAddress($to_addr, $to_name);

      if (defined('EMAIL_FROM')) {
        $this->mailer->From = EMAIL_FROM;
        $this->mailer->FromName = STORE_NAME;
        $this->mailer->AddReplyTo($from_addr, $from_name);
      } else {
        $this->mailer->From = $from_addr;
        $this->mailer->FromName = $from_name;
      }

      $this->mailer->Subject = $subject;

      $result = $this->mailer->Send();

      $this->mailer->clearAddresses();
      $this->mailer->clearAttachments();

      return $result;
    }

  }
If you need more help than that, you might have to pay one of the certified developers for assistance.
Skalia
Posts: 2
Joined: Thu Mar 04, 2021 1:17 pm

Re: Emails Not Sending

Post by Skalia »

Thank you. I will give it a try and reply with the results.
mendoh
Posts: 4
Joined: Thu Mar 04, 2021 6:10 pm

Re: Emails Not Sending

Post by mendoh »

Hello everybody.
Having exactly that same issue (=customer emails not sending via contact form) on a 1.0.8.0 verison and host says it can be solved by installing Phpmailer: too bad they do not give any directions on how to do that for Phoenix.
Any way out of this, other than switching host?
Thanks
Post Reply