Jump to content

Testing the Store's Email Settings


Recommended Posts

Please test:


In the admin skin template settings.index.php, near line 369:

         <div><label for="email_smtp_user">{$LANG.settings.smtp_user}</label><span><input name="config[email_smtp_user]" id="email_smtp_user" type="text" class="textbox" value="{$CONFIG.email_smtp_user}" autocomplete="off"></span></div>
         <div><label for="email_smtp_password">{$LANG.settings.smtp_pass}</label><span><input name="config[email_smtp_password]" id="email_smtp_password" type="password" class="textbox" value="{$CONFIG.email_smtp_password}" autocomplete="off"></span></div>
Add after:
<div><label for="smtp_test_url"><span style="color:red;font-weight:bold;">Save First, then</span> Launch Email Test</label><span>
    <button type="button" id="smtp_test_url" onclick="$.colorbox({ href:'{$STORE_URL}/{$SKIN_VARS.admin_file}?_g=xml&type=email&q={$CONFIG.email_smtp_password}&function=test' })">Test</button>

In admin, Manage Hooks, Code Snippets tab, Add Snippet:

Enabled: Checked

Unique ID: test_email@cubecart   (<== max 32 chars)

Execution Order: 1

Description: After saving email settings, makes a test email.

Trigger: class.ajax.load

Version: 1.0



PHP Code:

if (CC_IN_ADMIN && isset($_GET['type']) && $_GET['type'] == 'email' && isset($_GET['function']) && $_GET['function'] == 'test') {
    $pass = ($_GET['q']) ? $_GET['q'] : '';
    $test_mailer = Mailer::getInstance();
    $test_mailer->SMTPDebug = 2;
    $test_mailer->Debugoutput = "html";
    $test_mailer->Password = $pass;
    $test_mailer->AddAddress($GLOBALS['config']->get('config', 'email_address'));
    $test_mailer->Subject = "Testing CubeCart";
    $test_mailer->Body = "Testing from CubeCart v".CC_VERSION." at ".CC_STORE_URL;
    $test_mailer->AltBody = "Testing from CubeCart v".CC_VERSION." at ".CC_STORE_URL;
    // Send email
    $email_test_send_result = $test_mailer->Send();
    $email_test_results = @ob_get_contents();@ob_end_clean();

    if(!empty($email_test_results)) {
      $email_test_results_data = array (
            'request_url' => 'mailto:'.$GLOBALS['config']->get('config', 'email_address'),
            'request' => 'Subject: Testing CubeCart',
            'result' => $email_test_results,
            'error' => ($email_test_send_result) ? null : "Mailer Failed" ,
      $GLOBALS['db']->insert('CubeCart_request_log', $email_test_results_data);
      $json = $email_test_results;
    } else {
      $json = "Test failed to execute.";

This will give you the dialog the Mailer has with whatever you have set as the means and server to accept emails from your store. A copy of the dialog is saved in admin, Request Log.


The above needs testing! My development environment is not the same as a production environment.

Link to comment
Share on other sites

If the password has punctuation and other non-letter/number characters, then it may corrupt the data sent to CubeCart for testing. So, make this change in the template:






In the snippet:


$pass = ($_GET['q']) ? $_GET['q'] : '';


$pass = ($_GET['q']) ? base64_decode($_GET['q']) : '';

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.

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...