Jump to content

Contact email Error


Ben224
 Share

Recommended Posts

Hi,

My stores contact page which uses the default contact form from cubecart is not working.

I recieve emails ok but the content of the email recieved is stripped out completley and replaced with --------- ----------

I see the subject of the email and the senders email address but none of the senders content. I have replicated the problem by sending an email to myself and the issue persists.

Other emails i.e. order confirmation emails sent from the store are fine.

Can anyone help with this?

Many thanks in advance.

Link to comment
Share on other sites

Reviewing what's happening:

From the language array (tell us what language the store is operating in), this is the template:

%s <%s> wrote to %s:

---------------

%s

---------------



This email is sent from the stores master email address but it is possible to reply directly to the sender using the reply button on your email software.




The %s placeholders get filled as listed below.



If you get the dashed lines in the email, then we can narrow down the suspects considerably.



In cubecart.class.php line 1218 (for CC511), we (effectively) have this statement:


$mailer->Body = sprintf($GLOBALS['language']->contact['email_content'],

$_POST['contact']['name'], // first %s

$_POST['contact']['email'], // second %s

$department, // third %s, can be blank

strip_tags($_POST['contact']['enquiry']) // fourth %s

);




Do you also see the 'wrote to' and the 'This email is sent...' static phrases? If not, then it is extremely weird that you would still see the dashes. But hopefully you do.



That leaves the form element names as suspect. I looked at the Vanilla skin file, content.contact.php, and see that the element names: contact[name], contact, contact[dept], and contact[enquiry] are correct. I ask that you look at this file that is in use with your bespoke skin and verify the form element names.



There is also the matter that the code will strip_tags() on what is entered in the enquiry box. That means the use of angle characters (< >) could very easily cause any content between them to disappear.



I did a test:




Test 1a

< Test 1b >



Test 2a

< Test 2b

>








and this is what I got:




TestName <[email protected]> wrote to :

	    ---------------

	    Test 1





Test 2





	    ---------------

	    

	    This email is sent from the stores master email address but it is possible to reply directly to the sender using the reply button on your email software.



Link to comment
Share on other sites

Hi,

Thanks for the response. In answer to your questions:

The language is English UK

The code appears to be ok in cubecart.class.php here is the snippet which I have taken from line 1210 through 1227:

// Load content, assign variables

$mailer->IsHTML(false);

$mailer->AddAddress($email, $department);

if (isset($_POST['contact']['cc'])) {

$mailer->AddAddress($_POST['contact']['email'], strip_tags($_POST['contact']['name']));

}

$mailer->AddReplyTo($_POST['contact']['email'], strip_tags($_POST['contact']['name']));

$mailer->Subject = strip_tags($_POST['contact']['subject']);

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

// Send

if ($mailer->Send()) {

$GLOBALS['gui']->setNotify($GLOBALS['language']->documents['notify_document_contact']);

httpredir('index.php');

} else {

$GLOBALS['gui']->setError($GLOBALS['language']->documents['error_document_contact']);

}

}

}

I see the 'wrote to' and the 'This email is sent...' static phrases.

I have looked at the content.contact.php skin file which incidently I have never opened before all of the element name s appear correctly.

I havent used any special characters as part of my test email which I guess rules out the code stripping tags.

Can you offer any more advice?

Many thanks.

Link to comment
Share on other sites

Can we have the web address of your site?

As an experiment, change this statement to look like:

$mailer->Body = sprintf($GLOBALS['language']->contact['email_content'],$_POST['contact']['name']."TestName",$_POST['contact']['email']."TestEmail",$department."Dept",strip_tags($_POST['contact']['enquiry'].$GLOBALS['language']->contact['email_content']));

By concatenating the quoted text (bold and red), we will determine if there is anything in the POST array. If the POST array is somehow empty (although Subject seems to be there), the concatenated strings should still show. Note that we are putting into the enquiry variable a copy of the message template. Since it has < and >, I expect one of the %s placeholders to be gone.

Link to comment
Share on other sites

Hi,

Thanks again for the response. I made the change and run a test here are the results.

This is the email i get before changing the statement:

joe blogs wrote to [email protected]: --------------- --------------- This email is sent from the stores master email address but it is possible to reply directly to the sender using the reply button on your email software.

This is the email i get after changing the statement:

joe blogsTestName wrote to [email protected]: --------------- Dept --------------- This email is sent from the stores master email address but it is possible to reply directly to the sender using the reply button on your email software.

I note that capatcha is now not working.

Not sure that either of these make much sense to me.

Thanks.

Link to comment
Share on other sites

This:

joe blogsTestName wrote to [email protected]:

---------------

Dept

---------------



This email is sent from the stores master email address but it is possible to reply directly to the sender using the reply button on your email software.

is wrong. The second %s is missing.

TestName is in the right place, but TestEmail is supposed to be in angles just after TestName. And Dept is supposed to be just before the colon. There are only three %s placeholders in the template, thus the enquiry content is not getting used.

So the template has become damaged. Or CC5 is using a copy of the template located elsewhere.

Replace the copy of /language/definitions.xml with a fresh copy (it won't hurt anything to use a copy of this file from a CC515 package).

Next, use phpMyAdmin (or similar utility) to view the database table CubeCart_lang_strings, and look for 'type' and 'name' that suggests "contact" and "email_content". Delete that record.

Link to comment
Share on other sites

Thanks for your perseverance,

Would changing the language file overwrite the modifications I made to phrases via admin? I have changed quite alot of the wording and wonder if there were a way to avoid re-writing?

I note when I go into the 'Contact-Phrases used on the contact us page' adjacent to 'email_content' I have the following:

%s wrote to %s: --------------- %s --------------- This email is sent from the stores master email address but it is possible to reply directly to the sender using the reply button on your email software.

This appears to be exactly what is needed?

I guess i am trying to avoid spending hours going through and re-writing the language phrases if I can possibly avoid it?

Many thanks

Link to comment
Share on other sites

I positively believe that definitions.xml is never touched unless you have done so manually. All changes you make in the Language Phrase Editor is databased.

(When CubeCart is waking up, the file language.xml is loaded first, then any additions/overwrites from language-specific xml files in the language folder. Then any same-language edited phrases are fetched from the database overwriting previous.)

There is a problem when editing multi-line phrases in the Phrase Editor. All line breaks get removed. And one cannot tell which phrases are multi-line.

This phrase is not correct:

%s wrote to %s: --------------- %s --------------- This email is sent

As discussed in post#2 above, it must be (on one line for comparison):

%s <%s> wrote to %s: --------------- %s --------------- This email is sent

The <%s> is missing from your phrase.

I will also maintain that attempting to put a character sequence such as <%s> because one of the first things CubeCart does when waking up is to sanitize all POST and GET input. When sanitizing, tags are stripped.

So try (%s) instead.

Link to comment
Share on other sites

I would make a screen shot of what you want the Contact email to look like. Then you have something to go by if you have no choice but to start from scratch.

I sympathize with what you say about not wanting to redo so much work. Isn't it only the Contact email that is wrong? Surely you can pick up the appropriate part of a clean language file and try to put it in yours. If that doesn't work, at least you tried. Also, in the database - could you use a search/replace to change to "%s <%s> wrote" in the contact email info?? Again, if it doesn't work, you can still delete the record and start over.

I could well be completely off base with these suggestions, so take them with a grain of salt - I am NOT knowledgeable in code at all!!!!

Link to comment
Share on other sites

Hi, Thanks again for your thoughts and comments,

I have now replaced the definitions.xml with a fresh copy from the original Cubecart files and replaced the

%s wrote to %s: --------------- %s --------------- This email is sent

phrase to

%s <%s> wrote to %s: --------------- %s --------------- This email is sent

This didnt work so I then changed the <%s> to (%s) as suggested and I now have

%s (%s) wrote to %s: --------------- %s --------------- This email is sent

which works and my emails are fine. This last successful phrase now features in my database table and in the phrase editor. All appears to be well.

However I now have a problem with captcha. When loading the contact form in the first instance I see captcha as expected. But once the email has been sent captcha dissapears from my site entirley including on the shopping basket page. Captcha only reloads again after deleting cookies from my browser.

It appears I have solved one issue only to raise another. A little worrying as my site is now vunerable with captcha not functioning correctly.

Can you offer any more advice?

Thought about this a little more and wonder if the Captcha security system is smart enough to recognise that a user has allready passed the test once and doesnt require the same user to enter the test twice? In which case this explains why I am no longer presented with the captcha test a second time while using the same session cookie having allready completed the test on a different page? Does that make sense to anyone?

Link to comment
Share on other sites

I suggest you start a new conversation concerning the Captcha system.

I do not have a complete understanding of it, and it may behave differently in CC511 as opposed to CC514/515. So I cannot reply with any certainty. But as best I know, I am not aware of any "sticky-ness" to a positive result to a challenge. (It would be great if it actually did that!)

Link to comment
Share on other sites

Hi again,

Further to my previous post I have run a test using the demo provided at cubecart.com and am getting the same results as I describe above. I am now a little concerned that this may be a wider problem?

bsmither as a seasoned cubecart contributer can you advise how to bring this to the attention of the cubecart staff? I'm not familiar with the process. I think perhaps this needs looking at in further detail to eliminate any - what appears to be errors with the captcha function?

Thank you.

Link to comment
Share on other sites

  • 1 year later...

I see this is an old post however the problem still seems present in the latest 5.2.8. I have just tried to remove the text "This email is sent from the stores master email address but it is possible to reply directly to the sender using the reply button on your email software" from admin in languages > contact.  
 
 
I'm now received the email formatted as Ben224 stated "joe blogsTestName wrote to [email protected]: --------------- Dept --------------- This email is sent from the stores master email address but it is possible to reply directly to the sender using the reply button on your email software."
 

I have opened the copy of /languages/definitions.xml using notepad++ and strangely as you scroll down the colouring of the text of the .xml file is nicly colour coded Blue, Red, Purple Orange until you get to line 669 where the file then goes all black indicating to me something is wrong and this it the same line that relates to the email content that was edited " <string name="email_content" introduced="5.0.0"><![CDATA[%s <%s> wrote to %s:
---------------
%s
---------------

This email is sent from the stores master email address but it is possible to reply directly to the sender using the reply button on your email software.]]></string>"
 
 
try opening the /languages/definitions.xml in notepad++ to see line 669 and onwards it appears to be something with the <%s> and then when you hit the save it then removes the <%s>
 
I have also noticed on my store and the demo store that if you revert the code back using the icon on the right hand side it inserts the <%s>  but when you hit save it then removes it again.

 

if this file is saved in the database somewhere, maybe I need to find where its stored and manually add the <%s>??

Link to comment
Share on other sites

SOLVED:- I have just worked out you have to make the edit direct in the database.
1. Using phpMyAdmin find table Cubecart_lang_string
2. Find string ID 513
3. click browse tab and click the pencil then add:-
%s <%s> wrote to %s:
---------------
%s
---------------
 
 
this will make the emails work again. Note I have removed the text I wanted and will add a signature.
 
:yeahhh:

Note:- using the languages edit in the admin will otherwise break it

Link to comment
Share on other sites

One of the problems with the language editor, is that phrases have their tags stripped off.

 

Devellion has rewritten the code that does this, but they say it will be in CC6.

 

My solution is two parts in the Sanitize class:
* add 'string' to the $exempt array (I can think of a better, more descriptive key name)
* near lines 92-100, wrap the existing if/else construct in another test to skip the cleaning if the key at any dimension of a POSTed array is exempt:

if (!in_array($key, self::$exempt)) {
  if (is_array($value)) {
    self::_clean($data[$key]);
  } else {
    // If your HTML content isn't in a field with one of the following names, it's going!
    // We shold probably standardise the field names in the future
    if (!empty($value) && !in_array($key, self::$exempt)) {
      $data[$key] = self::_safety($value);
    }
  }
}

"until you get to line 669 where the file then goes all black"

 

That may be the first occurrence of angle delimiters in this xml file. And, perhaps NotePad++ does not have the intelligence to ignore everything found in CDATA blocks, but instead is seeing the tag delimeters as xml delimiters, and losing the nesting count.

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.

 Share

×
×
  • Create New...