shall I just set it to mailgun and leave it blank to stop sending all emails.

i don't want to use the log and delete log file later. I just want to flarum to stop sending all e-mails and forget about it.

luceos While the driver is set to log it will no longer send mails, but log them in the storage/logs/flarum.log file. I was assuming you wanted to temporarily prevent sending of mails?

  • 1Dot replied to this.
    • Best Answerset by Hari

    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!

    Hari But why you wan't to stop sending mails what's the issue ?

    • Hari replied to this.

      1Dot it's a bit complicated to explain, 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.

      i don't want to bother users with email notifications.
      i can not afford email service.
      i don't want my users to mark my domain as spam. (domain reputation)

      there are multiple reasons 🤔

        Hari So then what about registration. also it can be easily done by setting it to logs and breaking some flarum function by touching source.

        or
        You can simply set up a cron job to delete it for you easily.

        • Hari replied to this.

          1Dot So then what about registration.

          if mail server is disabled they can not register, they have no other choice other than social login.

          using css i'm hiding singup and forgot password.

          no need to edit core for this

          edit:

          Flarum currently does not send emails. This can be due to the selected driver, or errors in its configuration.

          so all outgoing mails will not goto log and wil not go through right? since did not configure mailgun

          • 1Dot replied to this.

            Hari no need to edit core for this

            OK then set up cron job to clear log in every 1 hour or maybe every 1 day or maybe every 1 month

            Like this

            * * * * *  find  /ramesh/cloud/web/flarum5/storage/logs/*.log -mtime +7 -exec rm -f {} \;

            Make sure to change /ramesh/cloud/web/flarum5 to your flarum directory.

            Hari so all outgoing mails will not goto log and wil not go through right? since did not configure mailgun

            But It will log error in storage/logs

            • Hari replied to this.

              1Dot you are not getting my question. i don't want to use log mode. i just want to set it to mailgun and leave it without configuring so all outgoing maills will go vanish

              i am just asking does it work like that?

                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.