Documentation

sendgrid - Sends an email with the SendGrid API

New in version 2.0.

Synopsis

Sends an email with a SendGrid account through their API, not through the SMTP service.

Options

parameter required default choices comments
from_address
yes
    the address in the "from" field for the email
    password
    yes
      password that corresponds to the username
      subject
      yes
        the desired subject for the email
        to_addresses
        yes
          a list with one or more recipient email addresses
          username
          yes
            username for logging into the SendGrid account

            Examples

            # send an email to a single recipient that the deployment was successful
            - sendgrid:
                username: "{{ sendgrid_username }}"
                password: "{{ sendgrid_password }}"
                from_address: "ansible@mycompany.com"
                to_addresses:
                  - "ops@mycompany.com"
                subject: "Deployment success."
                body: "The most recent Ansible deployment was successful."
              delegate_to: localhost
            
            # send an email to more than one recipient that the build failed
            - sendgrid
                  username: "{{ sendgrid_username }}"
                  password: "{{ sendgrid_password }}"
                  from_address: "build@mycompany.com"
                  to_addresses:
                    - "ops@mycompany.com"
                    - "devteam@mycompany.com"
                  subject: "Build failure!."
                  body: "Unable to pull source repository from Git server."
              delegate_to: localhost
            

            Notes

            Note

            This module is non-idempotent because it sends an email through the external API. It is idempotent only in the case that the module fails.

            Note

            Like the other notification modules, this one requires an external dependency to work. In this case, you’ll need an active SendGrid account.

            This is an Extras Module

            For more information on what this means please read Extras Modules

            For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Helping Testing PRs and Developing Modules.