Hari Yes it will work like that but it will then log every time whenever your mail goes I mean it will log error log every time mail system will work so its better to use cron and adding a cron job to delete logs.

1Dot But It will log error in storage/logs

😝 let it create email fail logs. i can delete them later.

if i use log mode it will trigger sending emails when it's set back to smtp or mail driver. (i dont want this to happen)

maybe someone can make an extension to stop all emails. so it will not create logs 😍

  • 1Dot replied to this.

    Hari when it's set back to smtp or mail driver.

    No it will not do that, It will just save logs.

    • Hari replied to this.

      1Dot

      luceos modify the mail driver to log and it will put the content of the mails in your log file instead. Make sure to remove the log or alternatively use another driver that works like a mail trap.

        Hari change the value mail_driver in your settings table to null and I think it should stop sending emails completely (including password reset and other authentication emails). Backup your settings table beforehand!

          luceos once could you check my first screenshot, i am leaving it unconfigured. i don't want to put my hands in db

          hope that helps my situation. without touching anything

          if possible consider adding feature in the core. Stop all Mails 😍

            If you disable all email but keep registrations open, new users will be unable to activate their accounts unless you also have a process to manually enable the users or you have an extension taking care of that. They will also be unable to change email or password. You also likely need to change some of Flarum translations because there are multiple texts that tell the user to expect an email.

            I believe there's also an email driver called array that will cause emails to be generated in memory but not sent.

              clarkwinkelmann thanks for taking time to explain the complications of disabling email.

              In my case I'm tired of handling duplicate accounts so we made its mandatory to login using social login. I don't want any user to change passwors so no worry.

              I kept registration open and hiding signup form using CSS for now

              Setting to mailgun and leaving it with no configuration will make mails to go to the mars 🚀 (I didn't get correct word 🙄) that is all I wanted .

              Hari i have (mod) participated in a discussion and a user posted something and i received an email notification even its not yet approved. 🤷‍♂️ i thought it was supposed to send emails when a post is approved. i don't know how it's working.

              If you have "Automatically follow discussions that I reply to" enabled in your preferences, that could be why you still got the email notification of an unapproved post. The post exists, it's just that it's hidden pending approval but can still possibly count as an event. That makes me wonder if a normal user without any Admin permissions still gets an email notification if a discussion they reply to has a post pending approval 🤔 doubtful nonetheless but I haven't really tested that theory.

              I know an approach I recommended on another forum powered by Flarum has helped tremendously with not hitting their email quota so quickly. The local extender code disables all user preferences that pertain to email notifications when a new user registers. In hindsight, I can share this code if needed 🙂

              The local extender does not disable password reset emails, unfortunately.

              clarkwinkelmann unless you also have a process to manually enable the users or you have an extension taking care of that

              Fortunately, we do hehe https://discuss.flarum.org/d/6485-email-verification-switch

                Ralkage The local extender code disables all user preferences that pertain to email notifications when a new user registers. In hindsight, I can share this code if needed

                I would love to try your local extender.

                Hari i don't want to put my hands in db

                You could also use a dummy SMTP server that just dumps the mails to /dev/null. Something like
                python -m smtpd -nc DebuggingServer localhost:2525 > /dev/null

                But getting your hands on the db seems to be the simpler option and works also on shared hosting.

                  Ralkage no, I will just use mailgun in un configured mode. Don't want to touch extend too

                  streaps cloudways don't have SMTP /mail by default at server level by selecting mail it will also act as trap to discard all mails

                  👍👍

                  streaps I would love to try your local extender.

                  This should take care of some of the notifications 🙂

                  <?php
                  
                  /*
                   * This file is part of Flarum.
                   *
                   * For detailed copyright and license information, please view the
                   * LICENSE file that was distributed with this source code.
                   */
                  
                  use Flarum\User\Event\Registered;
                  use Flarum\User\User;
                  use Flarum\Extend;
                  
                  return [
                      (new Extend\Event)
                          ->listen(Registered::class, function (Registered $event) {
                              foreach ([
                                  'postMentioned',
                                  'userMentioned',
                                  'newPost',
                                  'newDiscussionInTag',
                                  'newPostInTag',
                                  'newDiscussionTag',
                                  'discussionCreated',
                                  'postUnapproved',
                                  'userCreated'
                              ] as $key) {
                                  $event->user->setPreference(
                                      User::getNotificationPreferenceKey("{$key}", 'email'),
                                      false
                                  );
                              }
                              $event->user->setPreference('followAfterReply', false);
                  
                              $event->user->save();
                          })
                  ];

                  You should be able to add more to the array if you know the serialized type for the notification in question.

                    Ralkage That makes me wonder if a normal user without any Admin permissions still gets an email notification if a discussion they reply to has a post pending approval

                    I have the same thought about emails for new discussions pending approval. I know I as an admin am receiving new discussion emails for unapproved ones, because I am following all tags but I am hoping regular users that follow these tags are not also receiving notifications until they are approved. I don't know that this is the case though, because I don't receive another notification after approving it.

                      ctml flarum is working fine, I have mentioned that I actually do have mod privileges . (All permissions except access to admin panel)

                      Already tired of handling emails so I thought of turning it off. And if I turn it off users will come and visit my site the next day or later .. I get more page loads (returning
                      users) 🤪 not running ads though

                      Ralkage thanks for sharing it, if I updated my flarum will I lose this code from extend .php file? 🤔

                      • Hari replied to this.
                        9 months later