I'm facing an unexpected issue while using Nodemailer in Node.js via slack, The subject, which should be in the email subject line, is appearing in the message body. Below is a snippet of the relevant code
app.view('your_view_callback_id', async ({ ack, body, client }) => {
console.log('View Submission Payload:', JSON.stringify(body, null));
const subject = body.view.state.values.uik1r.sl_input.value;
const message = body.view.state.values["35GrF"].ml_input.value;
await sendEmail(client, subject, message)
await ack();
console.log('Acknowledged view submission', body);
});
async function sendEmail(subject, message){
console.log('Subject:', subject);
console.log('Message:', message);
const transporter = nodemailer.createTransport({
host: 'smtp.gmail.com',
port: 465,
secure: true,
auth: {
user: process.env.EMAIL_USER,
pass: process.env.EMAIL_PASSWORD,
}
})
const info = await transporter.sendMail({
from: "SlackEmail <motty6700@gmail.com>",
to: "techsupport@fidelitypayment.com",
subject:`This is just a test ${subject}`,
text: message
})
console.log("message sent:" + info.messageId);
console.log("Message info:", info);
console.log("message rejected:" + info.rejected)
}
the subject will be logged under the message params console.log('Message:', message); as you can see in the logs
Message: Tech support message sent:2ddfbd90-6f59-4cad-2263-b956ca9a4255@gmail.com "Tech support" was suppose to be under subject, the console.log(subject) doesn't even show up in the logs.
I am also encountering an issue with the placeholder in the subject line. I tried adding some static content, The placeholder text is not displaying correctly, resulting in unexpected content such as "This is just a test [object Object].", but this does show up in the subject line
here you can see the full payload
{
"type": "view_submission",
"team": {
"id": "T7W2JV1EV",
"domain": "fidelitypaymentserv"
},
"user": {
"id": "UUE442C3E",
"username": "mekstein",
"name": "mekstein",
"team_id": "T7W2JV1EV"
},
"api_app_id": "A0678L7J0A3",
"token": "2IOpUFegFduPd4egrd7BU7Il",
"trigger_id": "6269446301462.268086987505.739b418412dd1862ec8360bbe92ba936",
"view": {
"id": "V0683UZ2E1Z",
"team_id": "T7W2JV1EV",
"type": "modal",
"blocks": [
{
"type": "input",
"block_id": "uik1r",
"label": {
"type": "plain_text",
"text": "Subject",
"emoji": true
},
"optional": false,
"dispatch_action": false,
"element": {
"type": "plain_text_input",
"action_id": "sl_input",
"placeholder": {
"type": "plain_text",
"text": "Placeholder text for single-line input",
"emoji": true
},
"dispatch_action_config": {
"trigger_actions_on": [
"on_enter_pressed"
]
}
}
},
{
"type": "input",
"block_id": "35GrF",
"label": {
"type": "plain_text",
"text": "Message",
"emoji": true
},
"optional": false,
"dispatch_action": false,
"element": {
"type": "plain_text_input",
"action_id": "ml_input",
"placeholder": {
"type": "plain_text",
"text": "Placeholder text for multi-line input",
"emoji": true
},
"multiline": true,
"dispatch_action_config": {
"trigger_actions_on": [
"on_enter_pressed"
]
}
}
}
],
"private_metadata": "",
"callback_id": "your_view_callback_id",
"state": {
"values": {
"uik1r": {
"sl_input": {
"type": "plain_text_input",
"value": "Testing"
}
},
"35GrF": {
"ml_input": {
"type": "plain_text_input",
"value": "P200 is working as expected"
}
}
}
},
"hash": "1701380188.P487UEAT",
"title": {
"type": "plain_text",
"text": "Modal Title",
"emoji": true
},
"clear_on_close": false,
"notify_on_close": false,
"close": null,
"submit": {
"type": "plain_text",
"text": "Submit",
"emoji": true
},
"previous_view_id": null,
"root_view_id": "V0683UZ2E1Z",
"app_id": "A0678L7J0A3",
"external_id": "",
"app_installed_team_id": "T7W2JV1EV",
"bot_id": "B067LAB1GVB"
},
"response_urls": [],
"is_enterprise_install": false,
"enterprise": null
}
I have been working on this for hours already, I appreciate any assistace into resolving this issue.
As it seems you call the given method with three parameters:
await sendEmail(client, subject, message)
but it requires only two:
async function sendEmail(subject, message){
_client
to the method