Allow setting of email subject

Don't know how we missed that out in the earlier one 😅
This commit is contained in:
Badri Sunderarajan 2021-06-04 23:15:52 +05:30
parent 4b388e1a1b
commit 0806bae00e
2 changed files with 33 additions and 2 deletions

View file

@ -60,7 +60,7 @@ app.ws('/hit-send', (ws, request) => {
if (DEBUG) {
console.log(`\n\n-------------------------- BEGIN EMAIL --------------------------\n`)
console.log(`From: ${message.from}\nTo:${message.to}\n\n${message.text}`)
console.log(`From: ${message.from}\nTo:${message.to}\nSubject:${message.subject||'(no subject)'}\n\n${message.text}`)
console.log(`\n--------------------------- END EMAIL ---------------------------`)
} else {
console.log(`Sending email: ${message.from} -> ${message.to}`)
@ -70,6 +70,7 @@ app.ws('/hit-send', (ws, request) => {
from: message.from || process.env.CHIPCHOC_DEFAULT_SENDER,
to: message.to,
bcc: message.from || process.env.CHIPCHOC_DEFAULT_SENDER,
subject: message.subject,
text: message.text,
html: message.html,
})

View file

@ -13,6 +13,7 @@
let tkList = []
let fromEmail = ''
let subject = ''
let cookiePreviewData = { text: '', email: ''}
let cookiePreviewRow = 0
@ -237,6 +238,7 @@
emails.push({
from: fromEmail,
to: previewData.email,
subject: subject,
text: previewData.text,
html: converter.makeHtml(previewData.text),
})
@ -307,7 +309,16 @@
</div>
<div class="email-content">
<p>From: <input type="text" bind:value={fromEmail}/></p>
<div class="header">
<div class="form-group">
From
<input type="text" placeholder="chipchoc@example.com" bind:value={fromEmail}/>
</div>
<div class="form-group">
Subject
<input type="text" placeholder="Hi there" bind:value={subject}/>
</div>
</div>
<textarea bind:value={emailContent}/>
<p>
<strong>Detected fields:</strong>
@ -342,6 +353,7 @@
<div class="preview-header">
<p>From: {fromEmail || '[NOBODY!!!]'}</p>
<p>To: {cookiePreviewData.email || '[NOBODY!!!]'}</p>
<p>Subject: {subject || '[NO SUBJECT #notgood]'}</p>
<hr />
</div>
{@html converter.makeHtml(cookiePreviewData.text)}
@ -382,6 +394,7 @@
<div class="preview-header">
<p>From: {nowSending.from || '[NOBODY!!!]'}</p>
<p>To: {nowSending.to || '[NOBODY!!!]'}</p>
<p>Subject: {subject || '[NO SUBJECT #notgood]'}</p>
<hr />
{@html nowSending.html}
</div>
@ -438,6 +451,23 @@
margin: 4em auto;
}
.email-content .header {
max-width: 640px;
text-align: left;
margin: auto;
}
.email-content .form-group {
display: flex;
align-items: center;
}
.email-content .form-group input {
margin-left: 1em;
width: 100%;
border: 0
}
.email-content textarea {
width: 100%;
max-width: 640px;