haproxy/src/mailers.c
Aurelien DARRAGON 5694a98744 MAJOR: mailers: remove native mailers support
As mentioned in 2.8 announce on the mailing list [1] and on the wiki [2]
native mailers were deprecated and planned for removal in 3.3. Now is
the time to drop the legacy code for native mailers which is based on a
tcpcheck "hack" and cannot be maintained. Lua mailers should be used as
a drop in replacement. Indeed, "mailers" and associated config directives
are preserved because mailers config is exposed to Lua, which helps smoothing
the transition from native mailers to Lua based ones.

As a reminder, to keep mailers configuration working as before without
making changes to the config file, simply add the line below to the global
section:

       lua-load examples/lua/mailers.lua

mailers.lua script (provided in the git repository, adjust path as needed)
may be customized by users familiar with Lua, by default it emulates the
behavior of the native (now removed) mailers.

[1]: https://www.mail-archive.com/haproxy@formilux.org/msg43600.html
[2]: https://github.com/haproxy/wiki/wiki/Breaking-changes
2025-06-24 10:55:58 +02:00

51 lines
1.3 KiB
C

/*
* Mailer management.
*
* Copyright 2015 Horms Solutions Ltd, Simon Horman <horms@verge.net.au>
* Copyright 2020 Willy Tarreau <w@1wt.eu>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
*/
#include <stdlib.h>
#include <haproxy/action-t.h>
#include <haproxy/api.h>
#include <haproxy/errors.h>
#include <haproxy/mailers.h>
#include <haproxy/proxy.h>
#include <haproxy/server-t.h>
#include <haproxy/task.h>
#include <haproxy/time.h>
#include <haproxy/tools.h>
struct mailers *mailers = NULL;
/* Initializes mailer alerts for the proxy <p> using <mls> parameters.
*
* The function returns 1 in success case, otherwise, it returns 0 and err is
* filled.
*/
int init_email_alert(struct mailers *mls, struct proxy *p, char **err)
{
mls->users++;
free(p->email_alert.mailers.name);
p->email_alert.mailers.m = mls;
p->email_alert.flags |= PR_EMAIL_ALERT_RESOLVED;
return 0;
}
void free_email_alert(struct proxy *p)
{
if (!(p->email_alert.flags & PR_EMAIL_ALERT_RESOLVED))
ha_free(&p->email_alert.mailers.name);
ha_free(&p->email_alert.from);
ha_free(&p->email_alert.to);
ha_free(&p->email_alert.myhostname);
}