Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Export emails from database

GermontGermont New
edited November 2017 in Vanilla 2.0 - 2.8

Hello!

Is there an easy way to export the user emails for a monthly newsletter. The forum uses Vanilla 2.3.1
I am especially trying to avoid banned/disabled users, as many of them would mark the email as spam.

Thank you!

Best Answer

  • R_JR_J Ex-Fanboy Munich Admin
    Answer ✓

    With "disabled" you mean "deleted"? You can get the mails directly per SQL:

    SELECT Email
    FROM GDN_User
    WHERE Banned = 0
    AND Deleted = 0
    

    Or you can write a tiny little plugin which uses the query builder. It must create an endpoint and should look similar to that:

        public function pluginController_exportMails_create($sender) {
            $sender->permission('Garden.Community.Manage');
            $mails = Gdn::sql()
                ->select('Email')
                ->from('User')
                ->where([
                    'Deleted' => 0,
                    'Banned' => 0
                ])
                ->get()
                ->resultArray();
            print_r(array_column($mails, 'Email'));
        }
    

Answers

  • R_JR_J Ex-Fanboy Munich Admin
    Answer ✓

    With "disabled" you mean "deleted"? You can get the mails directly per SQL:

    SELECT Email
    FROM GDN_User
    WHERE Banned = 0
    AND Deleted = 0
    

    Or you can write a tiny little plugin which uses the query builder. It must create an endpoint and should look similar to that:

        public function pluginController_exportMails_create($sender) {
            $sender->permission('Garden.Community.Manage');
            $mails = Gdn::sql()
                ->select('Email')
                ->from('User')
                ->where([
                    'Deleted' => 0,
                    'Banned' => 0
                ])
                ->get()
                ->resultArray();
            print_r(array_column($mails, 'Email'));
        }
    
  • have you looked at the mailchimp plugin? you could use that as a guide

    https://github.com/vanillaforums-plugins/MailChimpIntegration

    grep is your friend.

  • GermontGermont New
    edited November 2017

    The owner need it for his shop, there is already a newsletter with html pattern and everything.
    @R_J
    There are still emails with Awaiting mail confirmation.
    But I even removed automatically with Notepad++ the lines with spamshit words.
    Thank you for great support ;)

  • R_JR_J Ex-Fanboy Munich Admin

    Check if adding "AND Confirmed = 1" to the conditions in the sql clause will give you "final" results.

Sign In or Register to comment.