{"id":23386,"library":"c7n-mailer","title":"Cloud Custodian Mailer","description":"Cloud Custodian Mailer is a reference mailer implementation for sending email notifications from Cloud Custodian policies. Version 0.6.49 requires Python >=3.9,<4.0. It is released irregularly alongside Cloud Custodian releases.","status":"active","version":"0.6.49","language":"python","source_language":"en","source_url":"https://github.com/cloud-custodian/cloud-custodian","tags":["cloud-custodian","mailer","aws","notifications","ses","sqs"],"install":[{"cmd":"pip install c7n-mailer","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Core Cloud Custodian library required for policy execution","package":"c7n","optional":false},{"reason":"AWS SDK for sending emails via SES or SQS","package":"boto3","optional":false},{"reason":"Used for rendering email templates","package":"jinja2","optional":false},{"reason":"Optional for using Redis as a queue backend","package":"redis","optional":true},{"reason":"Optional for LDAP-based address resolution","package":"ldap3","optional":true}],"imports":[{"note":"c7n-mailer is a separate package with its own namespace; underdot not subpackage of c7n","wrong":"from c7n.mailer import Mailer","symbol":"Mailer","correct":"from c7n_mailer import Mailer"},{"note":"AwsMailer is in the aws submodule","wrong":"from c7n_mailer import AwsMailer","symbol":"AwsMailer","correct":"from c7n_mailer.aws import AwsMailer"}],"quickstart":{"code":"from c7n_mailer import Mailer\nconfig = {\n    'queue_url': 'https://sqs.us-east-1.amazonaws.com/123456789012/my-queue',\n    'region': 'us-east-1',\n    'role': 'arn:aws:iam::123456789012:role/my-mailer-role',\n    'from_address': 'security@example.com'\n}\nmailer = Mailer(config, session=None)\n# For production, use a proper session or pass boto3 session","lang":"python","description":"Initialize a Mailer with an SQS queue URL and AWS config. Note: session can be None to use default boto3 credential chain."},"warnings":[{"fix":"Use 'from c7n_mailer import Mailer' instead of 'from c7n.mailer import mailer'.","message":"c7n-mailer 0.6.x uses 'c7n_mailer' imports, not 'c7n.mailer'. Older docs may reference the old dotted path.","severity":"breaking","affected_versions":">=0.6.0"},{"fix":"Ensure your SQS queue has a subscription to the SNS topic where Cloud Custodian publishes messages. Verify the queue ARN and policy allow SNS to send.","message":"The 'queue_url' config must point to an SQS queue that is subscribed to the SNS topic used by Cloud Custodian policies. Misconfiguration leads to no emails sent.","severity":"gotcha","affected_versions":"all"},{"fix":"Verify the email address or domain in AWS SES console. Use SES sandbox mode only for verified recipients.","message":"The 'from_address' must be verified in AWS SES (or sending domain verified) to send emails. Common reason for silent failures.","severity":"gotcha","affected_versions":"all"},{"fix":"Set requires-python = \">=3.9\" in your environment or use an older c7n-mailer version if locked to 3.8.","message":"Python 3.8 support dropped in c7n-mailer 0.6.42 (requires >=3.9). Upgrade Python environment if still on 3.8.","severity":"deprecated","affected_versions":">=0.6.42"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'pip install c7n-mailer' in the correct environment.","cause":"c7n-mailer is not installed or installed into a different Python environment.","error":"ModuleNotFoundError: No module named 'c7n_mailer'"},{"fix":"Check AWS credentials (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN) and IAM policy attached to the role used by c7n-mailer.","cause":"AWS credentials missing or expired, or the IAM role assumed does not have ses:SendEmail permission.","error":"botocore.exceptions.ClientError: An error occurred (InvalidClientTokenId) when calling the SendEmail operation: The security token included in the request is invalid."},{"fix":"Ensure config includes 'queue_url': 'https://sqs.<region>.amazonaws.com/<account-id>/<queue-name>'","cause":"Mailer config dictionary missing required 'queue_url' key.","error":"KeyError: 'queue_url'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}