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

feat(Send Email Node): Add support for sending text and html email simultaneously #6978

Merged
merged 1 commit into from
Aug 21, 2023

Conversation

pemontto
Copy link
Contributor

V1 allowed populating both html and text properties. The V2 node introduced a mutually exclusive selection between the two.

This PR adds back the ability to send both HTML and text in the email so it can degrade gracefully.

image

Snippet of resulting email body with both types:

----_NmP-27aec6e9cf4b8f1e-Part_1
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Text Email Body
----_NmP-27aec6e9cf4b8f1e-Part_1
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: 7bit

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><b>HTML EMAIL BODY<b>
----_NmP-27aec6e9cf4b8f1e-Part_1--

Test Workflow

Click to expand JSON workflow...
{
  "nodes": [
    {
      "parameters": {},
      "id": "9d81ba9f-d7de-4d4d-986d-fd643a8cfda4",
      "name": "When clicking \"Execute Workflow\"",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        280,
        580
      ]
    },
    {
      "parameters": {
        "fromEmail": "={{ $json.from }}",
        "toEmail": "={{ $json.to }}",
        "subject": "Test Email with HTML Body",
        "emailFormat": "html",
        "html": "=<b>HTML EMAIL BODY<b>",
        "options": {}
      },
      "id": "077a9963-72d0-4a90-8854-124869d7f3f7",
      "name": "Send HTML Email",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2,
      "position": [
        820,
        380
      ],
      "credentials": {
        "smtp": {
          "id": "2lCvKJhBMThyRcqJ",
          "name": "SMTP account"
        }
      }
    },
    {
      "parameters": {
        "fromEmail": "={{ $json.from }}",
        "toEmail": "={{ $json.to }}",
        "subject": "Test Email with Text Body",
        "text": "Text Email Body",
        "options": {}
      },
      "id": "fa6a26dc-725c-4af2-b212-a7f61e982365",
      "name": "Send Text Email",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2,
      "position": [
        820,
        580
      ],
      "credentials": {
        "smtp": {
          "id": "2lCvKJhBMThyRcqJ",
          "name": "SMTP account"
        }
      }
    },
    {
      "parameters": {
        "fromEmail": "={{ $json.from }}",
        "toEmail": "={{ $json.to }}",
        "subject": "Test Email with HTML and Text Body",
        "emailFormat": "both",
        "text": "Text Email Body",
        "html": "<b>HTML EMAIL BODY<b>",
        "options": {}
      },
      "id": "70d5ef42-f525-41f4-a7aa-4d73c074cfc3",
      "name": "Send Email with Both",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2,
      "position": [
        820,
        780
      ],
      "credentials": {
        "smtp": {
          "id": "2lCvKJhBMThyRcqJ",
          "name": "SMTP account"
        }
      }
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "from",
              "value": "user1@example.com"
            },
            {
              "name": "to",
              "value": "user2@example.com"
            }
          ]
        },
        "options": {}
      },
      "id": "f02a2373-e8fc-4f93-8d97-2eba56565b66",
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 2,
      "position": [
        500,
        580
      ]
    }
  ],
  "connections": {
    "When clicking \"Execute Workflow\"": {
      "main": [
        [
          {
            "node": "Set",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set": {
      "main": [
        [
          {
            "node": "Send HTML Email",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send Text Email",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send Email with Both",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
image

@github-actions
Copy link
Contributor

Great PR! Please pay attention to the following items before merging:

Files matching packages/**:

  • If fixing bug, added test to cover scenario.
  • If addressing forum or Github issue, added link to description.

Files matching packages/**/*.ts:

  • Added unit tests to cover new or updated functionality.

Files matching packages/nodes-base/nodes/**:

  • Added workflow tests for nodes if possible.

Make sure to check off this list before asking for review.

@pemontto pemontto changed the title ✨ Allow sending text and html email simultaneously fix(Send Email Node): ✨ Allow sending text and html email simultaneously Aug 19, 2023
@Joffcom Joffcom changed the title fix(Send Email Node): ✨ Allow sending text and html email simultaneously feat(Send Email Node): Add support for sending text and html email simultaneously Aug 19, 2023
@codecov
Copy link

codecov bot commented Aug 19, 2023

Codecov Report

Patch coverage: 9.37% and project coverage change: -0.01% ⚠️

Comparison is base (b6a00fe) 25.13% compared to head (a4042e9) 25.12%.
Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6978      +/-   ##
==========================================
- Coverage   25.13%   25.12%   -0.01%     
==========================================
  Files        3150     3150              
  Lines      192105   192163      +58     
  Branches    21159    21169      +10     
==========================================
- Hits        48288    48284       -4     
- Misses     142835   142897      +62     
  Partials      982      982              
Files Changed Coverage Δ
packages/cli/src/constants.ts 100.00% <ø> (ø)
.../MessageEventBusWriter/MessageEventBusLogWriter.ts 54.36% <0.00%> (-3.92%) ⬇️
...geEventBusWriter/MessageEventBusLogWriterWorker.ts 0.00% <0.00%> (ø)
...es/nodes-base/nodes/EmailSend/v2/send.operation.ts 0.00% <0.00%> (ø)
...ase/nodes/Google/Sheet/GoogleSheetsTrigger.node.ts 0.00% <0.00%> (ø)
...li/src/eventbus/MessageEventBus/MessageEventBus.ts 47.80% <13.04%> (-4.05%) ⬇️
packages/cli/src/CredentialsHelper.ts 25.35% <22.22%> (-0.14%) ⬇️
packages/cli/src/utils.ts 66.66% <50.00%> (-0.78%) ⬇️

... and 3 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@n8n-assistant n8n-assistant bot added community Authored by a community member node/improvement New feature or request labels Aug 19, 2023
@Joffcom Joffcom merged commit 3860d41 into n8n-io:master Aug 21, 2023
12 of 15 checks passed
This was referenced Aug 23, 2023
krynble added a commit that referenced this pull request Aug 23, 2023
# [1.4.0](https://github.com/n8n-io/n8n/compare/n8n@1.3.0...n8n@1.4.0)
(2023-08-23)


### Bug Fixes

* **core:** Add recoveryInProgress flag file
([#6962](#6962))
([7b96820](7b96820))
* **core:** Fix `continueOnFail` for expression error in Set
([#6939](#6939))
([d4fac05](d4fac05))
* **core:** Fix `import:workflow` command
([#6996](#6996))
([8c38d85](8c38d85))
* **core:** Replace throw with warning when deactivating a non-active
workflow ([#6969](#6969))
([b6a00fe](b6a00fe))
* **core:** Set up OAuth2 cred test
([#6960](#6960))
([4fc69b7](4fc69b7))
* **editor:** Do not flag dynamic load options issue on expression
([#6932](#6932))
([60a1ef0](60a1ef0))
* **editor:** Ensure community node install button tracks user agreement
([#6976](#6976))
([0ddfc73](0ddfc73))
* **editor:** Fix parsing for single quoted resolvables
([#6982](#6982))
([f32e993](f32e993))
* **editor:** Fix Remove all fields not removing values in resource
mapper ([#6940](#6940))
([e6cff3f](e6cff3f))
* **editor:** Prevent Code node linter from erroring on `null` parse
([#6934](#6934))
([40d3a29](40d3a29))
* **Google Sheets Node:** Fix short sheet name interpreted as range
([#6989](#6989))
([00268a0](00268a0))
* **Google Sheets Trigger Node:** Support sheet names with non-latin
characters ([#6970](#6970))
([052dd7c](052dd7c))
* **GraphQL Node:** Improve error handling
([#6955](#6955))
([41db637](41db637))
* **Mautic Node:** Fix issue with owner not being set correctly
([#6991](#6991))
([64b950f](64b950f))
* **Salesforce Node:** Fix Account update owner operation
([#6958](#6958))
([9b27878](9b27878))
* **Shopify Node:** Fix pagination when using options
([#6972](#6972))
([475d9c9](475d9c9))
* **Webhook Node:** Backward compatible form-data parsing for non-array
fields ([#6967](#6967))
([9455bcf](9455bcf))


### Features

* **core:** Add a warning to error workflows that cannot be started due
to permission or settings
([#6961](#6961))
([67b88f7](67b88f7))
* **core:** Add support for ready hooks, and credentials overwrite
endpoint in workers ([#6954](#6954))
([8f8a1de](8f8a1de))
* **editor:** Show banner for non-production licenses
([#6943](#6943))
([413570c](413570c))
* Remove PostHog event calls
([#6915](#6915))
([270946a](270946a))
* **Send Email Node:** Add support for sending text and html email
simultaneously ([#6978](#6978))
([3860d41](3860d41))

Co-authored-by: krynble <krynble@users.noreply.github.com>
@janober
Copy link
Member

janober commented Aug 30, 2023

Got released with n8n@1.4.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Authored by a community member node/improvement New feature or request Released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants