Instantiation
config.cfg (see Authentication). The constructor dies if API_KEY or API_USERNAME is missing.
Building a message
Messages are created with a single constructor call using named parameters:Attachments
Each attachment is a hashref with three keys. UseMIME::Base64 to encode the file content:
String::Util::trim removes the trailing newline that encode_base64 appends.
Send a message
Check delivery status
deliveryStatus values: delivered, opened, failed, pending.
Error handling
BothsendMessage and getEmailDisposition use TryCatch internally and die on API errors. Wrap calls in an eval block to catch failures: