function mail(description, %options)
{
var uid = options["patch"];
var mailthreadid;
if (defined uid)
mailthreadid = "P$uid";
function sendit(addr, subject, text)
{
text =~ s/'/'\\''/g;
text = <:>
: To: $addr
: Reply-To: $config_replyto
: Subject: $subject
: Message-ID: <$mailthreadid.$config_myemail>
: Message-ID: <$mailthreadid.${rand(-1)}.$config_myemail>
: References: <$mailthreadid.$config_myemail>
:
: $text
>;
system("( echo '$text' | $config_sendmail; ) >/dev/null 2>&1 &");
}
var username = defined userid ? sql_value(db, "SELECT user_name FROM user WHERE user_id = $userid") : "ANONYMOUS";
description =~ s/@@@/$username/;
var subject = (defined uid ? "[SM-$uid] " : "[SM] ") ~ (description =~ s/\n.*//Rsm);
var text = <:>
: SubMaster Action:
: $description
:
: On Patch [$uid]:
: ${sql_value(db, "SELECT patch_text FROM patch WHERE patch_uid = ${mysql::uid}") =~ s/^(---|Index:|diff).*//Rsm}
:
: --
: $config_baseurl?mode=patch&uid=$uid
:
: --
: $config_baseurl
>;
sendit(config_listaddr, subject, text);
if (defined uid) {
var addr = sql_value(db, <:>
: SELECT
: user.user_email
: FROM
: patch LEFT JOIN user ON patch.user_id_owner = user.user_id
: WHERE
: patch_uid = ${mysql::uid}
>);
if (defined addr and addr =~ /^\s*(\S+@\S+\.\S+)\s*$/)
sendit($1, "$subject (notify)", text);
}
}