1

Topic: Removing mysql forwarding rules

==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): 0.9.9 MARIADB edition
- Deployed with iRedMail Easy or the downloadable installer? downloadable installer
- Linux/BSD distribution name and version: Ubuntu 18.04.06 LTS
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MYSQL (MariaDB)
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro? No
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====

Hi all

I have some forwarding rules added to my forwardings table per the documentation.

I no longer need some of these rules and want to remove them.

(Specifically I have an email that was forwarding to itself and to another address and I've added a new rule to forward to a new designation, I want to remove the previous two rules to itself and the other address and just leave the new one)

I've inspected the table and can see the IDs of the rows I want to removed (no longer exactly sequential due to older users being removed) -- they are IDs 28 and 30.

Any ideas on how to safely remove these rules from the table?

Thank you!

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: Removing mysql forwarding rules

just remove them? i really dont understand your question, what is the problem with plain and simply removeing entrys from a database?

3 (edited by zebrinny 2022-07-27 04:59:59)

Re: Removing mysql forwarding rules

Ok wow that was an obnoxious response!

Ignoring Cthulhu rudeness, here's what to do for anyone else wanting some advice. This link here was quite useful -- freecodecamp . org/news/how-to-delete-a-row-in-sql-example-query/

(have to put spaces to allow it to post).

So first of all, start up mysql/mariadb:

-> sudo mysql -u root

Then you want to switch to the vmail database where the forwardings table lives -- forwardings is where the table that controls where mail is directed to lives.

-> USE vmail;

You'll get the prompt MariaDB [vmail]>

Then you want to show all the contents of the forwardings table with the following:

-> select * from forwardings;

This will spit out everything in the table. Every email address will be listed as it will have an entry to direct to itself.

So let's say you have an email address zebrinny@helping.com and currently delivering email to itself and to two addresses: iredmail@isgreat.com and mysql@isfun.com, and you only want to forward all email to mysql@isfun.com now.

In the output of the table, it might show the following:

id - address - forwarding -.... (a bunch more but that's okay for now)
3 - zebrinny@helping.com - zebrinny@helping.com
4 - zebrinny@helping.com - iredmail@isgreat.com
5 - zebrinny@helping.com - mysql@isfun.com

So to recap, id is just the id of the row, address is the email address on your system, forwarding is the email address it will forward emails to. Row ID 3 is making sure all emails sent to zebrinny@helping.com is actually being delivered to that inbox and row ids 4 and 5 are sending a copy to the other addresses.

To get what we want (which is all email sent to zebrinny@helping.com to go to mysql@isfun.com) we need to remove row 3 and 4.

To do that, and referring to the link at the top, we go:

-> DELETE FROM forwardings
WHERE id=3;

(yes there's a line break in-between, the command wont execute until you press enter after a semicolon)

If it worked, mariadb should come back with:
Query OK, 1 row affected (0.00 sec)

Then we want to do it again but for row 4:

-> DELETE FROM forwardings
WHERE id=4;

Again, if you did it right, it'll say:
Query OK, 1 row affected (0.00 sec)

And you're done!

Hit it with a:

-> select * from forwardings;

To check over the table again and make sure the offending records are gone, but you should be good!

If you've been editing users etc you want to FLUSH PRIVILEGES; also (Cant hurt anyway!) and then go EXIT;

Congrats!

Now there's probably a way to do both rows at once but I thought walking through slowly was the better option so there's no mistakes!

Hopefully this is helpful for someone else unsure of the right thing to do here!

4

Re: Removing mysql forwarding rules

zebrinny wrote:

Ok wow that was an obnoxious response!
Ignoring Cthulhu rudeness

"obnoxious"? "rudeness"? Are you kidding me?

Inserting / deleting / updating a row is quite basic SQL skill.