Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product
Vanilla 2.6 is here! It includes security fixes and requires PHP 7.0. We have therefore ALSO released Vanilla 2.5.2 with security patches if you are still on PHP 5.6 to give you additional time to upgrade.
Please upgrade to 2.3 here. The 2.2 and earlier branches are no longer being updated.

Export emails from database

GermontGermont New
edited November 2017 in Vanilla 2.0 - 2.3

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!

Comments

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    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'));
        }
    
    Germont
  • 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 Cheerleader & Troubleshooter Munich Moderator

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

Sign In or Register to comment.