Mail::...Config(3pm)

πŸ’– Mail::...Config(3pm) β€” the group chat version πŸ’–

okay so bestie, you found the manual page for Mail::MtPolicyd::Plugin::SqlUserConfig, and ngl it's a lil gem. It's a User Contributed Perl Documentation page, and we're about to make it make sense together. grab a snack, we're doing this πŸ’…


✨ NAME ✨

Mail::MtPolicyd::Plugin::SqlUserConfig β€” an mtpolicyd plugin for retrieving the user config of a user 🫢


🌸 VERSION 🌸

version 2.05


πŸ¦‹ DESCRIPTION πŸ¦‹

So what does this little icon actually do? This plugin goes and retrieves a JSON string from an SQL database, and then it merges that data structure into the current session. Periodt. πŸ’«

And like, why would you want that? Because you could use it to retrieve configuration values for users straight from a database. user-specific config, served fresh, no cap πŸ“


πŸŽ€ PARAMETERS πŸŽ€

  • sql_query (default: SELECT config FROM user_config WHERE address=?) β€” this is the SQL query that retrieves the JSON configuration string. Heads up: the content of the first row/column is what gets used. only the first one, bestie, don't come for me about the rest πŸ™ˆ
  • field (default: recipient) β€” the request field used in the sql query to retrieve the user configuration. that's the vibe check for "whose config are we even talking about" πŸ‘‘

🌈 EXAMPLE USER SPECIFIC GREYLISTING 🌈

okay this is the part where it gets good. first things first: create the following table in the SQL database πŸ‘‡

CREATE TABLE `user_config` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `address` varchar(255) DEFAULT NULL,
  `config` TEXT NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `address` (`address`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1

INSERT INTO TABLE `user_config` VALUES( NULL, 'karlson@vomdach.de', '{"greylisting":"on"}' );

(yes, INSERT INTO TABLE β€” that's literally what the page says, I'm not touching it, copying commands exactly is the whole assignment πŸ’–)

then, in mtpolicyd.conf:

db_dsn="dbi:mysql:mail"
db_user=mail
db_password=password

<Plugin user-config>
  module = "SqlUserConfig"
  sql_query = "SELECT config FROM user_config WHERE address=?"
</Plugin>
<Plugin greylist>
  enabled = "off" # off by default
  uc_enabled = "greylisting" # override with value of key 'greylisting' is set in session
  module = "Greylist"
  score = -5
  mode = "passive"
</Plugin>

and that's the whole glow-up. the greylist plugin is off by default, and uc_enabled = "greylisting" means it gets overridden with the value of the key greylisting is set in session. iconic setup, honestly 🌟


πŸ’œ AUTHOR πŸ’œ

Markus Benning <ich@markusbenning.de> β€” the main character who wrote this 🫑


This software is Copyright (c) 2014 by Markus Benning <ich@markusbenning.de>. give credit where credit is due, always πŸ’…

This is free software, licensed under:

The GNU General Public License, Version 2, June 1991

πŸ’€ reminder bestie: this page is from perl v5.38.2, dated 2024-05-26, and it's filed under Mail::...Config(3pm) in the User Contributed Perl Documentation. so if you're reading this on a wildly different perl, just, like, be aware. mwah, bye, go read your logs 🧚✨
πŸ“¦ where this page comes from