Rust Requires Chilkat v11.0.0+
Rust
Request a SpamAssassin score for a sample email
See more Email Object Examples
Submit a synthetic message to Postmark’s SpamCheck endpoint. The service receives the complete MIME you provide. Request a short result and check both the HTTP status and the API success field before reading the numeric score. SpamCheck API documentation.
Chilkat Rust Downloads
let mut success = false;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
let email = chilkat::Email::new();
email.set_from("Workshop team <events@example.com>");
success = email.add_to("Alex Rivera", "alex@example.net").is_ok();
if !success {
println!("{}", email.last_error_text());
return;
}
email.set_subject("Workshop registration");
email.set_body("Your workshop registration is confirmed.");
let request = chilkat::JsonObject::new();
let _ = request.update_string("email", &email.get_mime().unwrap_or_default());
let _ = request.update_string("options", "short");
let http = chilkat::Http::new();
http.set_require_ssl_cert_verify(true);
let resp = chilkat::HttpResponse::new();
success = http.http_json("POST", "https://spamcheck.postmarkapp.com/filter", &request, "application/json", &resp).is_ok();
if (!success) || (resp.status_code() != 200) {
println!("SpamCheck request failed. HTTP {}", resp.status_code());
return;
}
let result = chilkat::JsonObject::new();
if result.load(&resp.body_str()).is_err() {
println!("{}", result.last_error_text());
return;
}
if !result.bool_of("success") {
println!("{}", result.string_of("message").unwrap_or_default());
return;
}
println!("SpamAssassin score: {}", result.string_of("score").unwrap_or_default());