Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+9 votes
2.7k views
in Q2A Core by

This is the error:

Question2Answer fatal error:

Could not send email confirmation

Stack trace:

require() /home/lawstr/public_html/index.php:31
require() /home/lawstr/public_html/qa-include/qa-index.php:163
qa_get_request_content() /home/lawstr/public_html/qa-include/qa-page.php:755
require() /home/lawstr/public_html/qa-include/qa-page.php:188
qa_send_new_confirm() /home/lawstr/public_html/qa-include/qa-page-confirm.php:50

Here is how to reproduce it:

0- in admin>permission set the "who can ask question" to users with confirmed emails

1- create a user account using your email, e.g abcd@efg.com

2- you will see that everything goes fine and you can ask for re-sending the confirmation of email, etc.

NOW:

create a facebook account using same email address (abcd@efg.com)and

now try to login using that facebook account.

you accept the facebook app and so for no problem.

Q2A will ask you for confirming your email address then, ( or you can ask a question for undernith recaptcha you can click for confirming the email address)

now if you ask for resending the confim email, that error above raises

why?

because these two accounts were both created using same email address, therefore the q2a instead of complaining at the time of register using facebook login, simply replaced the email address of the second account with blank!""

and sending email to blank email address casues that error!

you can see it for yourself, the second account's email which was created by facebook registration has an email of blank!

clicking on the send confirmation link keads to this error that was generated on question2answer website:

PS: I am using Q2A 1.5.4:

 

Thank you Gid for your time in advance.

Q2A version: Q2A 1.5.4
by
Thanks - I'll look into this for Q2A 1.6.
by
Hey Gid green,
just wanted to remind you to fix this for 1.6 as you promised.

3 Answers

+1 vote
by

Here is a temporary solution to avoid that ugly message to appear!

in qa-app-users-edit.php, change the definition of function

    function qa_send_new_confirm($userid)
/*
    Set a new email confirmation code for the user and send it out
*/
    {
        if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }
        
        require_once QA_INCLUDE_DIR.'qa-db-users.php';
        require_once QA_INCLUDE_DIR.'qa-db-selects.php';
        require_once QA_INCLUDE_DIR.'qa-app-emails.php';

        $userinfo=qa_db_select_with_pending(qa_db_user_account_selectspec($userid, true));
        //--
        if (!qa_send_notification($userid, $userinfo['email'], $userinfo['handle'], qa_lang('emails/confirm_subject'), qa_lang('emails/confirm_body'), array(
            '^url' => qa_get_new_confirm_url($userid, $userinfo['handle']),
        )))
        if(strlen($userinfo['email'])<3){
            echo 'Error! Same email is used by another user. Please change your email.<br/>';
            qa_fatal_error('Could not send email confirmation');
        }else{
                        qa_fatal_error('Could not send email confirmation!');
        }
        //--
    }

in qa-base.php, change the definition of function

function qa_fatal_error($message)
/*
 Display $message in the browser, write it to server error log, and then stop abruptly
 */
{
    if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }
    //--
    echo 'Fatal error:<P><FONT COLOR="red">'.qa_html($message, true).'. Please contact the admin of this website!</FONT></P>';
    $sLog='<P>Stack trace:<P>';
    $backtrace=array_reverse(array_slice(debug_backtrace(), 1));
    foreach ($backtrace as $trace){
    $sLog = $sLog.'<FONT COLOR="#'.((strpos(@$trace['file'], '/qa-plugin/')!==false) ? 'f00' : '999').'">'.
    qa_html(@$trace['function'].'() '.@$trace['file'].':'.@$trace['line']).'</FONT><BR>';
    }
    @error_log('PHP Question2Answer fatal error: '.$message.$sLog);
    //--
    qa_exit('error');
}

by
Why this solution is a temporary? So what is a best solution for that? Thanks for that! :)
+1 vote
by
Q2A will prevent duplicate registrations if the email address matches, and in addition not allow the sending of confirmation emails to blank addresses from users previously registered. Fix will appear in Q2A 1.6-dev soon.
...