Ansible mail 模块发送邮件

通过 mail 模块发送邮件的例子如下:

# cat mail.yml
---
- name: Send email notification
  mail:
    host: smtp.exmail.qq.com
    port: 465
    secure: starttls
    username: test01@qq.com
    from: test01@qq.com
    password: passwd
    to: test02@qq.com,test03@qq.com
    subtype: html
    subject: "Ports {{ ports }} just {{ actions }}"
    body: '<b>Release Notes:</b> <br>
              Date: "{{ commit_id.end }}" <br>
              Action: "{{ actions }}" <br>
              Branch: "{{ branch }}" <br>
              Commit_id: "{{ commit_id.stdout }}" <br>
              Ports: "{{ ports }}" <br>
              Hosts: "{{ play_hosts }}".'
  delegate_to: localhost
  run_once: True
点赞

发表评论

电子邮件地址不会被公开。 必填项已用*标注