HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Sending E-Mails from Plugin
Hello everyone,
I wrote a Plugin. It's createing a checkbox inside the 'new discussion' form. If this checkbox is checked, a notification email should be send to all forum members (We're only 50 people, it's a small private project). This was working well, but since Version 2.6 the forum does only send this email to only one user (the first one of the database query result) - but I'm using a foreach, this confuses me.
My code is:
$Users = Gdn::SQL() ->select('Email') ->from('User') ->where('Deleted',false) ->where('Verified',true) ->get(); foreach ($Users as $User){ $emailer = new Gdn_Email(); $emailer->subject('Testsubject'); $email = $emailer->getEmailTemplate(); $email->setTitle('TestTitle') ->setLead($Discussion->Name) ->setMessage('Test Text.' . $out) ->setButton(externalUrl($DiscussionUrl), 'Read more', '#fff', '#ff0000') ->setFooter('Test Footer Text '); $emailer->setEmailTemplate($email); $emailer->to($User->Email); $emailer->send(); $emailer->to(''); }
Does anyone know, whats wrong here?
Thank you in advance
Tim
0
Comments
No, I do not know but I would change the content of the loop to make it more effective and maybe it already helps - who knows? You do not need to instantiate the mail class again and again.
But if you do not use personal mail texts, I would do it without a loop:
Hi R_J,
yes I already did it like your suggestion and than I modified it to the way shown, but both ways are not working...
This is also not working. :-( The first user from the users table will get the E-Mail in BCC, but no one else.
When I print the array to a page, it includes all user email adresses.
Thanks, BR Tim
have you consider this may be a restriction of the mail sever?
many mail delivery companies and hosts are not happy to deliver transactional mail and use a number of strategies to prevent. Controlling how many email can be sent within n second is one strategy.
What mail server are you using?
grep is your friend.
This could be possible, but it was working great for a time... That's why i'm confused. I'm using a smtp server from my web hoster, nothing special I guess. I'll ask them if they're preventing that since a few weeks.
If you haven't changed anything that is the most likely. Many hosts do you support transactional mall. Even common email services like Gmail do not. This is common mistake people make, they assume that because they are give a SMTP solution or find a service they accept volumes of transactional mail.
grep is your friend.
Even the services that do specialise in it can be tricky. Spark post is good but there can be a couple of false flags before they confirm you are legit. That mean they lock the account down including logging into the backend.
grep is your friend.
Spark post will look at things like external URLs I'm emails
grep is your friend.
Ok, I understand, but if I use the bcc method this have to work in my opinion. Because that's only one E-Mail for the SMTP Server, or not?
Sorry to bother you, but no one in BCC will get an email, only the one in $emailer->To
Also tried to build a string with all adresses inside
If I print the var $bcc, the addresses will appear, so $bcc is not empty, but still no one will get a mail.
If I set
$emailer->Bcc('my@mailadress.com');
I'll get an mail in bcc.Summary:
My Webhoster told me the following limits:
I guess I'm far away from both limits!
You can just call call
$emailer->bcc();
multiple times, no need to concatenateMy themes: pure | minusbaseline - My plugins: CSSedit | HTMLedit | InfiniteScroll | BirthdayModule | [all] - PM me about customizations
VanillaSkins.com - Plugins, Themes and Graphics for Vanillaforums OS