Export emails from database
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!
0
Best Answer
-
R_J Admin
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')); }
1
Answers
With "disabled" you mean "deleted"? You can get the mails directly per SQL:
Or you can write a tiny little plugin which uses the query builder. It must create an endpoint and should look similar to that:
have you looked at the mailchimp plugin? you could use that as a guide
https://github.com/vanillaforums-plugins/MailChimpIntegration
grep is your friend.
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
Check if adding "AND Confirmed = 1" to the conditions in the sql clause will give you "final" results.