Jump to content

Mail Function stop working


eeyk

Recommended Posts

Hello, Since 4 days now suddenly my mail() function quit working.
Does anyone know a solution for this problem?

Every mail my website send in cubecart gets this error in the email log :"Could not instantiate mail function."
i have contact my webhosting and ask if the mail() function was turned off but he said it's turned on.
 

 

Link to comment
Share on other sites

3 hours ago, bsmither said:

In admin, Store Settings, Advanced tab, there is a [Test] button just below the section where email details are entered. The test results may show what is actually wrong.

 

Thank you for responding!


the error i get is .

i changed my domain to *****
"It isn't possible to get a definitive test result for the "PHP mail() Function" method.

"

We have attempted to send a test email to "noreplay@******.nl" with the subject of "Testing PHP mail() Function" Please note that it can take ten minutes or even longer for a busy mail server to deliver email. Don't forget to check your spam folder!

This method can fail if the server hasn't been configured properly and may refuse to send mail from "untrusted" sources such as Hotmail, Yahoo, AOL etc…. We recommend using an email address from a domain hosted on this server such as sales@*****.nl for example and this may need to be setup form within your web hosting account."

"


Sadly after this message i do not receive any mail.


Kind regards.

Edited by eeyk
Link to comment
Share on other sites

Your hosting provider may have provided you with a control panel for your account.

That control panel should have a utility to test and monitor email activity. Please examine your control panel and determine what email configuration features may provide you with a means to track test emails sent and received. You may need to get your hosting provider to assist you.

 

 

Link to comment
Share on other sites

2 hours ago, bsmither said:

Your hosting provider may have provided you with a control panel for your account.

That control panel should have a utility to test and monitor email activity. Please examine your control panel and determine what email configuration features may provide you with a means to track test emails sent and received. You may need to get your hosting provider to assist you.

 

 

I did ask my Webhosting and they told me that they didn't change anything, because in 2020 and 2021 and 2022 until 10 august everything was working fine.
i also update to the latest version of Cubecart, i do see the mail in the logs but it's not sending anything. it's very weird and frustrating. 

because i have to manual mail all my costumers now. 



i hope someone can give the golden tip.

 

Kind regards.

 

 

Link to comment
Share on other sites

I bet when you upgraded CC to the latest version, the upgrade over wrote some of your Admin files. I use "beyond compare" to see which files have changed.

Once found I can upload the old version of the file to get the email to work.

/classes/cubecart.class.php version CC645 has at about line 1551 

 $mailer->Body  = sprintf($GLOBALS['language']->contact['email_content'], $_POST['contact']['name'], $_POST['contact']['email'], $department, $enquiry, $_SERVER['REMOTE_ADDR']);

CC647 does not have $_SERVER['REMOTE_ADDR'] 

I found that without $_SERVER['REMOTE_ADDR'] my contact page stiopped working.

Edited by harrisorganic
update
Link to comment
Share on other sites

On 8/17/2022 at 3:48 PM, harrisorganic said:

I bet when you upgraded CC to the latest version, the upgrade over wrote some of your Admin files. I use "beyond compare" to see which files have changed.

Once found I can upload the old version of the file to get the email to work.

/classes/cubecart.class.php version CC645 has at about line 1551 

 $mailer->Body  = sprintf($GLOBALS['language']->contact['email_content'], $_POST['contact']['name'], $_POST['contact']['email'], $department, $enquiry, $_SERVER['REMOTE_ADDR']);

CC647 does not have $_SERVER['REMOTE_ADDR'] 

I found that without $_SERVER['REMOTE_ADDR'] my contact page stiopped working.

Thank you for your response. i have change the line in my classes folder on my FTP server but it still gives the same error sadly. 

Link to comment
Share on other sites

Just to be clear:

Quote

 

CC647 does not have $_SERVER['REMOTE_ADDR'] 

I found that without $_SERVER['REMOTE_ADDR'] my contact page stopped working.

 

Allow me to assert that your installation to need this parameter matches also an edit made to the Mailer class for a custom requirement.

The stock code beginning with CC644 (earliest I looked) does not have this parameter.

Link to comment
Share on other sites

 

1 hour ago, bsmither said:

Just to be clear:

Allow me to assert that your installation to need this parameter matches also an edit made to the Mailer class for a custom requirement.

The stock code beginning with CC644 (earliest I looked) does not have this parameter.

I assume you are refering to classes/mailer.class.php. I can not find any difference between CC647 and CC645 code in classes/mailer.class.php.

Could there be some other change to require $_SERVER['REMOTE_ADDR']?

Link to comment
Share on other sites

It would help if an error log could be examined when you see a problem with mailing the Contact Us submission, where $_SERVER['REMOTE_ADDR'] is not getting sent to $mailer->Body.

For you, the line pointed to uses sprintf with five arguments supplied to the language phrase 'email_content' in the Contact group. So, you may have edited that language phrase to use that fifth argument, saved it (saved in the database to survive upgrades).

Thus, after upgrading, it will be necessary to re-apply hard-coded customizations. Otherwise, the sprintf function will be missing an argument which will have PHP log a complaint.

Note that there is a hook available here. A code snippet could be constructed to assign to $mailer->Body a string of your own making, with whatever arguments you want/need. Code snippets survive upgrades.

Link to comment
Share on other sites

The System Error Log in admin will catch most of the errors. However, if an error is Fatal, the error might not get logged here.

PHP's error_log (as specified by statements in ini-custom.inc.php) will catch them all as it does not depend on a running script.

 

Link to comment
Share on other sites

This is from the system error

https://www.harrisorganicwine.com.au/shop/index.php?_a=contact

                Today, 08:48       [<strong>Notice</strong>] /var/www/vhosts/harrisorganicwine.com.au/httpdocs/shop/cache/skin/9eca190828e3efc84c0add0bc635532128059db2_0.file.box.language.php.php:24 - Trying to get property 'value' of non-object

Other lines of error are attached.

I also note that there are a lot of system errors with urls of php.php

Cubecart.class.php.Date Message.docx

Edited by harrisorganic
Link to comment
Share on other sites

I think nearly all of the log entries matching the examples shown in the document provided, relate to the parts of the skin template system you have stripped out (Language chooser, Featured box, Sale Items box, Newsletter box, Live Help, Debug, and Skin chooser).

Looking at the source HTML delivered to my browser, I see that there is a removed text entry field for the person's phone number.

This will cause the form to not even be submitted if the form validation fails.

In the file /skins/ho/js/3.cubecart.validate.js, at lines 66-97, there are the rules for the contact form.

Remove 92-94:
            },
            'contact[phone]': {
                phone: $('#validate_phone').text()

Remove 83-85:
            },
            'contact[phone]': {
                phone: true

What I do not know is this: How smart is the Validator? If the Validator does not find a text entry input field having the name contact['phone'], even with a rule referencing it, will the validator still submit the form?

According to this, the Validator does not check non-existing fields (from five years ago):

https://forum.jquery.com/topic/jquery-validate-check-that-a-field-exists-before-validating

In other words, I do not know if this edit will fix things.

FYI: The core code in cubecart.class.php, says only that 'email', 'name', 'subject', 'enquiry' are the only required fields. So maybe an issue will get posted in the Github that compares the Validator rule for the phone being required, but the core code does not.

Edited by bsmither
  • Like 1
Link to comment
Share on other sites

Hi Brian,

I made the changes to the javascript file and reverted the changes to /classes/cubecart.class.php. The email test from the contact page did not go through as you suspected.

re:  that compares the Validator rule for the phone being required, but the core code in cubecart.class does not.  I assume the phone number is required for the order side of CC.

Duncan

Link to comment
Share on other sites

  • 4 months later...

Now my CC649 version of  /classes/cubecart.class.php does not have $_SERVER['REMOTE_ADDR'] in line 1574.

No system errors showed up. Just the error message at the contact page again as per the CC647 upgrade.

I found that without $_SERVER['REMOTE_ADDR'] in line 1574 my contact page did not work.

Link to comment
Share on other sites

To review:

Line 1574 of cubecart.class.php uses sprintf with a 'template' (Language phrase contact['email_content']) requiring no less and no more than four parameters to fill specifier spots in the template.

The language phrase is found in the definitions.xml file.

Both files will get overwritten in an upgrade. As such, making edits to either file will disappear.

The language phrase can be changed in admin, Languages, of which any changes will be databased to survive upgrades.

Perhaps you made it so that a fifth parameter will fill a new fifth specifier slot in the language phrase.

Unfortunately, in stock code, the sprintf function that uses that phrase is still only supplying four parameters.

If you have more specifiers than parameters to match them, sprintf returns NOTHING. Thus, the mailer will have no "body" and will probably not even attempt to send an email.

Fortunately, there is a hook at line 1575 we can use to add new data. The hook code will find and replace a special sequence in the language string with the new data.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...