Skip to main content


msg:code — Get or set the message code



msg:code(number, str);

number: number (optional)
str: string (optional)


Get or set the message code. In the case of a "get call", the parameter list is left empty. In the case of "set call", if number is 0, then the number is taken from str, otherwise, the number is prefixed to str. If the string passed to str is multi-line and/or the number needs to be prefixed, then the string will be adjusted so that it forms a valid (potentially multi-line) response string.


Do not call this function from validate_set_binding.

local codestr = msg:code();

msg:code("421", "Too much spam.");

Enable this function with the statement require('msys.extended.message');.


During reception, you will likely want to set the code by using vctx:set_code.

See Also

Was this page helpful?