pub fn set_header(
    ncc: NativeCallContext<'_>,
    header: &str,
    value: &str
) -> EngineResult<()>
Expand description

Replace an existing header value by a new value, or append a new header to the message.

Args

  • header - the name of the header to set or add.
  • value - the value of the header to set or add.

Effective smtp stage

All of them. Even though the email is not received at the current stage, vsmtp stores new headers and will add them on top to the ones received once the preq stage is reached.

Be aware that if you want to set a header value from the original message, you must use set_header in the preq stage and onwards.

Examples

"Subject: The initial header value\r\n",
"\r\n",
"Hello world!\r\n",
#{
  preq: [
    rule "set_header" || {
      msg::set_header("Subject", "The header value has been updated");
      msg::set_header("Subject", identifier("The header value has been updated again"));
      state::accept(`250 ${msg::get_header("Subject")}`);
    }
  ]
}

rhai-autodocs:index:9