Mail Sender (New)

Send emails implemented in Python with embedded image support.

Email · Mail Sender (New)

Details

IDMail Sender (New)
ProviderOpen Source
CategoryEmail
From Version5.0.0
Docker Imagedemisto/python3:3.12.13.10404775
Supported ModulesAgentix Cloud Runtime Security Cloud Posture Security XSIAM EDR Cortex Cloud

README

This is a Python script for sending emails, which includes various attachment implementations.

Supported Authentication

This integration does not support NTLM authentication. If you are using Exchange as the SMTP server for sending mail and receive the error message: No suitable authentication method found. make sure that you enable Basic Authentication for SMTP authentication in your Exchange environment.

 This example shows Basic Authentication on Exchange 2010:

image

Configure Mail Sender on Cortex XSOAR

  1. Navigate to Settings > Integrations > Servers & Services.
  2. Search for Mail Sender (New).
  3. Click Add instance to create and configure a new integration instance.
    • Name: a textual name for the integration instance
    • Mail server hostname or IP address
    • SMTP Port
    • Credentials
    • Password
    • Sender address: if the sender address is different than the log-in credentials and password, the sender address must have permission to send emails.
    • FQDN: Fully Qualified Domain Name, used in EHLO
    • Use TLS for connection
    • Do not validate server certificate (not secure)
  4. Click Test to validate the URLs, token, and connection.

Commands

  1. Send email: send-mail

1. Send email


Sends an email.

Basic Command

send-mail

Input
Argument Name Description
to Recipient email address
cc Additional recipient email address
bcc Additional recipient email address
subject Subject of the email
body Content of the email in plain text
htmlBody Content of the email in html format
replyTo

If recipient chooses to reply, reply will automatically be sent to this email address

attachIDs  Comma-separated list of IDs of war room entries that contain the files you want to attach to the email
attachNames

A comma-separated list of new names, to rename attachments, in correspondence with the order that they were attached to the email.

Examples:

  • To rename first and third file: attachNames=new_fileName1,,new_fileName3
  • To rename second and fifth files: attachNames=,new_fileName2,,,new_fileName5
attachCIDs

A comma-separated list of CIDs to embed attachments inside the email itself

transientFile

Textual name for attached file. Multiple files are supported.

transientFileContent

Content for attached file. Multiple files are supported.

Example:

transientFile.1="t1.txt" transientFileContent.1="test 1" transientFile.2="t3.txt" transientFileContent.2="test 3"

transientFileCID

CID for attached file if you want it inline. Multiple files are supported.

Example:

transientFile.1="t1.txt" transientFileContent.1="test 1" transientFileCID.1="t1.txt@xxx.yyy" transientFile.2="t3.txt" transientFileContent.2="test 3"

templateParams

Replace {varname} variables with values from this parameter.

Expected values are in the form of a JSON document

Example:

{  
   "varname":{  
      "value":"some value",
      "key":"context key"
   }
}

Each var name can either be provided with a value or a context key to retrieve the value from. Note that only context data is accessible for this argument, while incident fields are not.

additionalHeader

Custom header to add to an email.

sender The sender address to use for the email. If provided, it overrides the default sender address configured in the integration instance.

 

Command Example
!send-mail to="name@example.com" cc="test@example.com" bcc="admin@example.com" subject="Topic of the day" replyTo="replymail@example.com" attachIDs="111@02a9cf84-c76f-4b2e-8840-c6b2a85c53cf,129@02a9cf84-c86f-4b2e-8840-c6c2a89c53cf" attachNames="notcookie.png,cookie.jpg" attachCIDs="notcookie,mycookie" transientFile="friendly_note.txt" transientFileContent="this is some text" htmlBody="<html>
<body>
<p>HELLO</p>
<img src=\"cid:mycookie\"/>
</body>
</html>"

 

About CIDs

CIDs work by attaching the image to the email you are sending, and then using standard HTML image tags that reference that image to embed it in the email when the user opens it.

 Example:
<html>
  <body>
    <img src=\"cid:radomimagecid\"/>
  </body>
</html>

CID Limitations

CID is not supported on all email applications. It is supported mainly on Outlook.

On web applications, such as Gmail, adding CID duplicates the attachment: as an actual attachment and embedded in the text body.

Configuration parameters

  • host — Mail server hostname or IP address (required)
  • port — SMTP Port (required)
  • credentials — Credentials
  • from — Sender address (required)
  • fqdn — Fully Qualified Domain Name (FQDN) - used in EHLO
  • tls — Connection Security
  • insecure — Trust any certificate (not secure)

Commands (1)

  • send-mail

    Send an email.

category: Email
provider: Open Source
commonfields:
  id: Mail Sender (New)
  version: -1
sectionorder:
- Connect
- Collect
configuration:
- display: Mail server hostname or IP address
  name: host
  required: true
  type: 0
  section: Connect
- defaultvalue: '25'
  display: SMTP Port
  name: port
  required: true
  type: 0
  section: Connect
- display: Credentials
  name: credentials
  type: 9
  required: false
  section: Connect
- defaultvalue: Cortex XSOAR <noreply@demisto.com>
  display: Sender address
  name: from
  required: true
  type: 0
  section: Connect
  additionalinfo: Sender address can be specified as 'user@host.com' or 'Full Name <user@host.com>'
- display: Fully Qualified Domain Name (FQDN) - used in EHLO
  name: fqdn
  type: 0
  required: false
  section: Connect
- display: Connection Security
  additionalinfo: The connection security. The `SSL/TLS` first establishes a secure `SSL/TLS` connection and conducts SMTP over that connection, and STARTTLS starts with unencrypted SMTP and then switches to SSL/TLS to ensure security.
  name: tls
  defaultvalue: "None"
  type: 15
  options:
  - None
  - STARTTLS
  - SSL/TLS
  required: false
  section: Connect
- defaultvalue: 'false'
  display: Trust any certificate (not secure)
  name: insecure
  type: 8
  required: false
  section: Connect
description: Send emails implemented in Python with embedded image support.
display: Mail Sender (New)
name: Mail Sender (New)
script:
  commands:
  - arguments:
    - default: true
      description: Email addresses for the 'To' field.
      isArray: true
      name: to
    - description: Email addresses for the 'Cc' field.
      isArray: true
      name: cc
    - description: Email addresses for the 'Bcc' field.
      isArray: true
      name: bcc
    - description: Subject for the email to be sent.
      name: subject
    - description: The contents (body) of the email to be sent in plain text.
      name: body
    - description: The contents (body) of the email to be sent in HTML format.
      name: htmlBody
    - description: Address that should be used to reply to the message.
      name: replyTo
    - description: A comma-separated list of IDs of war room entries that contain the files that should be attached to the email.
      isArray: true
      name: attachIDs
    - description: A comma-separated list to rename file-names of corresponding attachments IDs. (e.g. rename first two files - attachNames=file_name1,file_name2. rename first and third file - attachNames=file_name1,,file_name3).
      isArray: true
      name: attachNames
    - description: A comma-separated list of CIDs to embed attachments inside the email itself.
      isArray: true
      name: attachCIDs
    - description: Desired name for attached file. Multiple files are supported as comma-separated list. (e.g. transientFile="t1.txt,temp.txt,t3.txt" transientFileContent="test 2,temporary file content,third file content" transientFileCID="t1.txt@xxx.yyy,t2.txt@xxx.zzz").
      isArray: true
      name: transientFile
    - description: Content for attached file. Multiple files are supported as comma-separated list. (e.g. transientFile="t1.txt,temp.txt,t3.txt" transientFileContent="test 2,temporary file content,third file content" transientFileCID="t1.txt@xxx.yyy,t2.txt@xxx.zzz").
      isArray: true
      name: transientFileContent
    - description: CID for attached file if we want it inline. Multiple files are supported as comma-separated list. (e.g. transientFile="t1.txt,temp.txt,t3.txt" transientFileContent="test 2,temporary file content,third file content" transientFileCID="t1.txt@xxx.yyy,t2.txt@xxx.zzz").
      isArray: true
      name: transientFileCID
    - description: 'Replace {varname} variables with values from this argument. Expected values are in the form of a JSON document like {"varname": {"value": "some value", "key": "context key"}}. Each var name can either be provided with the value or a context key to retrieve the value from. Note that only context data is accessible for this argument, while incident fields are not.'
      name: templateParams
    - description: 'A CSV list of additional headers in the format: headerName=headerValue. For example: "headerName1=headerValue1,headerName2=headerValue2".'
      isArray: true
      name: additionalHeader
    - description: Raw email message to send. If provided, all other arguments, but to, cc and bcc, will be ignored.
      name: raw_message
    - auto: PREDEFINED
      defaultValue: Text
      description: Whether message response body type is text or HTML.
      name: bodyType
      predefined:
      - HTML
      - Text
    - description: Indicates whether to render the email body.
      name: renderBody
      auto: PREDEFINED
      predefined:
      - 'true'
      - 'false'
    - description: The sender address to use for the email. If provided, it overrides the default sender address configured in the integration instance.
      name: sender
      required: false
    description: Send an email.
    name: send-mail
  runonce: false
  script: '-'
  type: python
  subtype: python3
  dockerimage: demisto/python3:3.12.13.10404775
tests:
- Mail Sender (New) Test
fromversion: 5.0.0