Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add module read_mail #57357

Open
wants to merge 14 commits into
base: devel
from

adding documentation

  • Loading branch information...
caiohsramos authored and gprangel committed Apr 25, 2019
commit 714119f15f279bd464104ddb8561a26aa5c26b45
@@ -1,6 +1,6 @@
#!/usr/bin/python

# Copyright: (c) 2018, Terry Jones <terry.jones@example.org>
# Copyright: (c) 2018, Caio Ramos <caioramos97@gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

ANSIBLE_METADATA = {
@@ -11,59 +11,100 @@

DOCUMENTATION = '''
---
module: my_sample_module
module: read_mail
short_description: This is my sample module
short_description: Module for reading emails from a IMAP server
version_added: "2.4"
version_added: "2.8"
description:
- "This is my longer description explaining my sample module"
- "Get emails from a IMAP server using basic filtering rules an returns an email count and list"
options:
name:
host:
description:
- This is the message to send to the sample module
- IMAP server host
required: false
default: localhost
port:
description:
- IMAP server port
required: false
default: 993 or 143
username:
description:
- Username to get the emails
required: true
new:
password:
description:
- Control to demo if the result of this module is changed or not
- Password to get the emails
required: true
ssl:
description:
- Whether to use SSL or not
required: false
extends_documentation_fragment:
- azure
default: true
mailbox:
description:
- Select the mailbox to use
required: false
default: INBOX
filter:
description:
- Default IMAP filters. Checkout the options at blablabla.
required: false
default: ALL
author:
- Your Name (@yourhandle)
- Caio Ramos (@caiohsramos)
- Gabriely Rangel (@)
'''

EXAMPLES = '''
# Pass in a message
# simplest use
- name: Test with a message
my_new_test_module:
name: hello world
read_mail:
host: imap.myhost.com
password: mypass
# pass in a message and have changed true
# no ssl and custom username and port
- name: Test with a message and changed output
my_new_test_module:
name: hello world
new: true
# fail the module
read_mail:
host: imap.myhost.com
port: 42
username: myuser
password: mypass
ssl: no
# using filters
- name: Test failure of the module
my_new_test_module:
name: fail me
read_mail:
host: imap.myhost.com
port: 42
username: myuser
password: mypass
filter:
subject: mysubject
to: example@example.com
'''

RETURN = '''
original_message:
description: The original name param that was passed in
host:
description: The original host param that was passed in
type: str
returned: always
message:
description: The output message that the sample module generates
username:
description: The username used in the request
type: str
returned: always
mails:
description: A list of the email's headers that satisfied the filter
type: list
returned: always
mails_count:
description: The email count that satisfied the filter
type: int
returned: always
'''
import imaplib

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.