Changeset 3829867
- Timestamp:
- 11/27/2026 02:51:09 PM (75 minutes ago)
- Location:
- digimail-smtp
- Files:
-
- 2 added
- 18 edited
- 1 copied
-
tags/2.5.1 (copied) (copied from digimail-smtp/trunk )
-
tags/2.5.1/build/index.asset.php (modified) (1 diff)
-
tags/2.5.1/build/index.js (modified) (2 diffs)
-
tags/2.5.1/digimail-smtp.php (modified) (2 diffs)
-
tags/2.5.1/includes/Plugin.php (modified) (1 diff)
-
tags/2.5.1/includes/Queue.php (modified) (1 diff)
-
tags/2.5.1/includes/Rest.php (modified) (1 diff)
-
tags/2.5.1/includes/Review.php (added)
-
tags/2.5.1/readme.txt (modified) (3 diffs)
-
tags/2.5.1/src/Alerts.tsx (modified) (2 diffs)
-
tags/2.5.1/uninstall.php (modified) (1 diff)
-
trunk/build/index.asset.php (modified) (1 diff)
-
trunk/build/index.js (modified) (2 diffs)
-
trunk/digimail-smtp.php (modified) (2 diffs)
-
trunk/includes/Plugin.php (modified) (1 diff)
-
trunk/includes/Queue.php (modified) (1 diff)
-
trunk/includes/Rest.php (modified) (1 diff)
-
trunk/includes/Review.php (added)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/src/Alerts.tsx (modified) (2 diffs)
-
trunk/uninstall.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
digimail-smtp/tags/2.5.1/build/index.asset.php
r3829755 r3829867 5 5 'wp-i18n' 6 6 ), 7 'version' => ' b0b2b2c165474d304b79'7 'version' => 'dd914ccc1737aec07d63' 8 8 ); -
digimail-smtp/tags/2.5.1/build/index.js
r3829755 r3829867 10 10 (0,i.__)("Last 30 days: %1$s of %2$s submissions blocked. See them in the Customers tab.","digimail-smtp"),o(s.blocked),o(s.checked)))))}function W({summary:e}){const t=C(),[a,n]=(0,l.useState)(null),[s,r]=(0,l.useState)(""),[c,u]=(0,l.useState)(""),[_,h]=(0,l.useState)(""),b=(0,l.useCallback)(()=>d("guard/log").then(e=>n(e.items)).catch(e=>r(e.message)),[]);(0,l.useEffect)(()=>{b()},[b]);const y=Object.entries(e.reasons).slice(0,4);return(0,l.createElement)(E,{title:(0,i.__)("Spam blocked","digimail-smtp"),aside:(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:b,"aria-label":(0,i.__)("Reload","digimail-smtp")},(0,l.createElement)(w,{name:"refresh",size:15}))},(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.sprintf)(/* translators: 1: blocked submissions, 2: checked submissions. */ /* translators: 1: blocked submissions, 2: checked submissions. */ 11 11 (0,i.__)("Last 30 days: %1$s of %2$s submissions blocked. No email was sent for them and they were not saved as contacts.","digimail-smtp"),o(e.blocked),o(e.checked)),y.length>0&&(0,l.createElement)(l.Fragment,null," ",(0,i.__)("Most common reasons:","digimail-smtp")," ",y.map(([e,t])=>`${m[e]??e} (${o(t)})`).join("; "),".")),s&&(0,l.createElement)("p",{className:"dms-error"},s),!a&&!s&&(0,l.createElement)("div",{className:"dms-skel",style:{height:240}}),a&&0===a.length&&(0,l.createElement)(k,{icon:(0,l.createElement)(w,{name:"shield",size:26}),title:(0,i.__)("Nothing blocked yet","digimail-smtp")},(0,i.__)("Bot submissions show up here. If a real customer says the form did not work, find them here and click “Not spam”.","digimail-smtp")),a&&a.length>0&&(0,l.createElement)("table",{className:"dms-table"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Sender","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Form","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Why","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Time","digimail-smtp")),(0,l.createElement)("th",null))),(0,l.createElement)("tbody",null,a.map(e=>(0,l.createElement)(l.Fragment,{key:e.id},(0,l.createElement)("tr",null,(0,l.createElement)("td",{className:"dms-ellipsis"},(0,l.createElement)("strong",null,e.name||e.email||"—"),e.name&&e.email&&(0,l.createElement)("div",{className:"dms-muted dms-small"},e.email),e.phone&&(0,l.createElement)("div",{className:"dms-muted dms-small"},e.phone)),(0,l.createElement)("td",{className:"dms-small"},[g(e.source),e.form].filter(Boolean).join(" · "),(0,l.createElement)("div",{className:"dms-muted"},e.ip)),(0,l.createElement)("td",{className:"dms-small"},(0,l.createElement)("ul",{className:"dms-reasons"},e.reasons.map(e=>(0,l.createElement)("li",{key:e},m[e]??e))),e.text&&(0,l.createElement)("button",{type:"button",className:"dms-link",onClick:()=>h(_===e.id?"":e.id)},_===e.id?(0,i.__)("Hide message","digimail-smtp"):(0,i.__)("Show message","digimail-smtp"))),(0,l.createElement)("td",{className:"dms-small dms-muted",title:new Date(1e3*e.at).toLocaleString()},p(new Date(1e3*e.at).toISOString())),(0,l.createElement)("td",{className:"dms-actions"},(0,l.createElement)(f,{size:"sm",variant:"secondary",busy:c===e.id,onClick:()=>(async e=>{u(e);try{await d("guard/restore",{id:e}),n(t=>(t??[]).filter(t=>t.id!==e)),t((0,i.__)("Marked as not spam. This address will not be blocked again.","digimail-smtp"))}catch(e){t(e.message,"bad")}finally{u("")}})(e.id)},(0,i.__)("Not spam","digimail-smtp")))),_===e.id&&(0,l.createElement)("tr",{className:"dms-subrow"},(0,l.createElement)("td",{colSpan:5},(0,l.createElement)("pre",{className:"dms-message"},e.text))))))),a&&a.length>0&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.sprintf)(/* translators: %s: number of entries kept. */ /* translators: %s: number of entries kept. */ 12 (0,i._n)("The latest %s blocked submission is kept on this website.","The latest %s blocked submissions are kept on this website.",a.length,"digimail-smtp"),o(a.length))))}const R={added:{label:(0,i.__)("New","digimail-smtp"),tone:"ok",hint:(0,i.__)("Added to the contact list.","digimail-smtp")},existing:{label:(0,i.__)("Already in list","digimail-smtp"),tone:"info",hint:(0,i.__)("This address was already in the list.","digimail-smtp")},blocked:{label:(0,i.__)("Blocked","digimail-smtp"),tone:"wait",hint:(0,i.__)("Unsubscribed, bounced or reported spam before, so it is not added back.","digimail-smtp")},invalid:{label:(0,i.__)("Invalid email","digimail-smtp"),tone:"bad",hint:(0,i.__)("The address cannot receive email.","digimail-smtp")}},q=e=>[g(e.source??"")||e.source,e.form].filter(Boolean).join(" · ")||(0,i.__)("Other","digimail-smtp");function B({state:e,go:t}){const a=C(),[n,s]=(0,l.useState)(""),[m,r]=(0,l.useState)(""),[u,_]=(0,l.useState)(1),[b,y]=(0,l.useState)(null),[N,S]=(0,l.useState)(""),[M,T]=(0,l.useState)(!1),[D,x]=(0,l.useState)(!1),z=(0,l.useCallback)(e=>{const t=new URLSearchParams;return e&&t.set("page",String(u)),n&&t.set("form",n),m.trim()&&t.set("q",m.trim()),t.toString()},[u,n,m]),$=(0,l.useCallback)(()=>d(`entries?${z(!0)}`).then(e=>{y(e),S("")}).catch(e=>S(e.message)),[z]);(0,l.useEffect)(()=>{const e=setTimeout($,m?300:0);return()=>clearTimeout(e)},[$,m]);const P=b?Math.max(1,Math.ceil(b.total/b.per_page)):1,F=b?b.forms.reduce((e,t)=>e+t.count,0):0,I=e.settings.capture.enabled,O=e.guard;return(0,l.createElement)("div",{className:"dms-stack"},!I&&(0,l.createElement)(v,{tone:"info",title:(0,i.__)("Saving form contacts is off","digimail-smtp"),action:(0,l.createElement)(f,{variant:"secondary",size:"sm",onClick:()=>t("settings")},(0,i.__)("Turn on","digimail-smtp"))},(0,i.__)("Turn it on in Settings and the people who fill in your forms show up here.","digimail-smtp")),b&&(b.forms.length>0||O.enabled)&&(0,l.createElement)("div",{className:"dms-formcards"},(0,l.createElement)("button",{type:"button",className:D||""!==n?"":"is-on",onClick:()=>{x(!1),s(""),_(1)}},(0,l.createElement)("span",null,(0,i.__)("All forms","digimail-smtp")),(0,l.createElement)("strong",null,o(F))),b.forms.map(e=>(0,l.createElement)("button",{key:e.key,type:"button",className:D||n!==e.key?"":"is-on",onClick:()=>{x(!1),s(e.key),_(1)}},(0,l.createElement)("span",{className:"dms-ellipsis",title:q(e)},e.form||g(e.source??"")||e.source||(0,i.__)("Other","digimail-smtp")),(0,l.createElement)("strong",null,o(e.count)),(0,l.createElement)("small",{className:"dms-ellipsis"},e.form&&e.source?(g(e.source)||e.source)+" · ":"",(0,i.sprintf)(/* translators: %s: time of the last entry. */ /* translators: %s: time of the last entry. */12 (0,i._n)("The latest %s blocked submission is kept on this website.","The latest %s blocked submissions are kept on this website.",a.length,"digimail-smtp"),o(a.length))))}const q={added:{label:(0,i.__)("New","digimail-smtp"),tone:"ok",hint:(0,i.__)("Added to the contact list.","digimail-smtp")},existing:{label:(0,i.__)("Already in list","digimail-smtp"),tone:"info",hint:(0,i.__)("This address was already in the list.","digimail-smtp")},blocked:{label:(0,i.__)("Blocked","digimail-smtp"),tone:"wait",hint:(0,i.__)("Unsubscribed, bounced or reported spam before, so it is not added back.","digimail-smtp")},invalid:{label:(0,i.__)("Invalid email","digimail-smtp"),tone:"bad",hint:(0,i.__)("The address cannot receive email.","digimail-smtp")}},R=e=>[g(e.source??"")||e.source,e.form].filter(Boolean).join(" · ")||(0,i.__)("Other","digimail-smtp");function B({state:e,go:t}){const a=C(),[n,s]=(0,l.useState)(""),[m,r]=(0,l.useState)(""),[u,_]=(0,l.useState)(1),[b,y]=(0,l.useState)(null),[N,S]=(0,l.useState)(""),[M,T]=(0,l.useState)(!1),[D,x]=(0,l.useState)(!1),z=(0,l.useCallback)(e=>{const t=new URLSearchParams;return e&&t.set("page",String(u)),n&&t.set("form",n),m.trim()&&t.set("q",m.trim()),t.toString()},[u,n,m]),$=(0,l.useCallback)(()=>d(`entries?${z(!0)}`).then(e=>{y(e),S("")}).catch(e=>S(e.message)),[z]);(0,l.useEffect)(()=>{const e=setTimeout($,m?300:0);return()=>clearTimeout(e)},[$,m]);const P=b?Math.max(1,Math.ceil(b.total/b.per_page)):1,F=b?b.forms.reduce((e,t)=>e+t.count,0):0,I=e.settings.capture.enabled,O=e.guard;return(0,l.createElement)("div",{className:"dms-stack"},!I&&(0,l.createElement)(v,{tone:"info",title:(0,i.__)("Saving form contacts is off","digimail-smtp"),action:(0,l.createElement)(f,{variant:"secondary",size:"sm",onClick:()=>t("settings")},(0,i.__)("Turn on","digimail-smtp"))},(0,i.__)("Turn it on in Settings and the people who fill in your forms show up here.","digimail-smtp")),b&&(b.forms.length>0||O.enabled)&&(0,l.createElement)("div",{className:"dms-formcards"},(0,l.createElement)("button",{type:"button",className:D||""!==n?"":"is-on",onClick:()=>{x(!1),s(""),_(1)}},(0,l.createElement)("span",null,(0,i.__)("All forms","digimail-smtp")),(0,l.createElement)("strong",null,o(F))),b.forms.map(e=>(0,l.createElement)("button",{key:e.key,type:"button",className:D||n!==e.key?"":"is-on",onClick:()=>{x(!1),s(e.key),_(1)}},(0,l.createElement)("span",{className:"dms-ellipsis",title:R(e)},e.form||g(e.source??"")||e.source||(0,i.__)("Other","digimail-smtp")),(0,l.createElement)("strong",null,o(e.count)),(0,l.createElement)("small",{className:"dms-ellipsis"},e.form&&e.source?(g(e.source)||e.source)+" · ":"",(0,i.sprintf)(/* translators: %s: time of the last entry. */ /* translators: %s: time of the last entry. */ 13 13 (0,i.__)("last %s","digimail-smtp"),p(e.last_at))))),O.enabled&&(0,l.createElement)("button",{type:"button",className:"is-spam "+(D?"is-on":""),onClick:()=>x(!0)},(0,l.createElement)("span",null,(0,l.createElement)(w,{name:"shield",size:14})," ",(0,i.__)("Spam blocked","digimail-smtp")),(0,l.createElement)("strong",null,o(O.blocked)),(0,l.createElement)("small",null,(0,i.__)("last 30 days","digimail-smtp")))),D&&(0,l.createElement)(W,{summary:O}),!D&&(0,l.createElement)(E,null,(0,l.createElement)("div",{className:"dms-toolbar"},(0,l.createElement)("div",{className:"dms-search"},(0,l.createElement)(w,{name:"search",size:16}),(0,l.createElement)("input",{value:m,onChange:e=>{r(e.target.value),_(1)},placeholder:(0,i.__)("Search name, email or phone","digimail-smtp"),"aria-label":(0,i.__)("Search","digimail-smtp")})),(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:()=>$(),"aria-label":(0,i.__)("Reload","digimail-smtp")},(0,l.createElement)(w,{name:"refresh",size:15})),(0,l.createElement)(f,{variant:"secondary",size:"sm",busy:M,disabled:!b||0===b.total,onClick:async()=>{T(!0);try{const e=await d(`entries/export?${z(!1)}`),t=URL.createObjectURL(new Blob([e.csv],{type:"text/csv;charset=utf-8"})),a=document.createElement("a");a.href=t,a.download="khach-dien-form.csv",a.click(),URL.revokeObjectURL(t)}catch(e){a(e.message,"bad")}finally{T(!1)}}},(0,l.createElement)(w,{name:"download",size:15})," ",(0,i.__)("Export CSV","digimail-smtp"))),e.capture.pending>0&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.sprintf)(/* translators: %s: number of contacts. */ /* translators: %s: number of contacts. */ 14 (0,i._n)("%s new entry is on its way to DigiMail.","%s new entries are on their way to DigiMail.",e.capture.pending,"digimail-smtp"),o(e.capture.pending))),N&&(0,l.createElement)("p",{className:"dms-error"},N),!b&&!N&&(0,l.createElement)("div",{className:"dms-skel",style:{height:320}}),b&&0===b.entries.length&&(0,l.createElement)(k,{icon:(0,l.createElement)(w,{name:"users",size:26}),title:m||n?(0,i.__)("No matching entries","digimail-smtp"):(0,i.__)("No form entries yet","digimail-smtp")},m||n?(0,i.__)("Try another filter.","digimail-smtp"):(0,i.__)("When someone fills in a form or places an order, they show up here with the form and page they used.","digimail-smtp")),b&&b.entries.length>0&&(0,l.createElement)("table",{className:"dms-table"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Customer","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Phone","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Form","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Page","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Result","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Time","digimail-smtp")))),(0,l.createElement)("tbody",null,b.entries.map(e=>{const t= R[e.outcome];return(0,l.createElement)("tr",{key:e.id},(0,l.createElement)("td",{className:"dms-ellipsis"},(0,l.createElement)("strong",null,e.name||e.email),e.name&&(0,l.createElement)("div",{className:"dms-small dms-muted dms-ellipsis"},e.email),e.company&&(0,l.createElement)("div",{className:"dms-small dms-muted dms-ellipsis"},e.company)),(0,l.createElement)("td",{className:"dms-small"},e.phone?(0,l.createElement)("a",{href:`tel:${e.phone.replace(/[^\d+]/g,"")}`},e.phone):(0,l.createElement)("span",{className:"dms-muted"},"—")),(0,l.createElement)("td",{className:"dms-small dms-ellipsis"},q(e)),(0,l.createElement)("td",{className:"dms-small dms-ellipsis"},e.page?(0,l.createElement)("a",{href:e.page,target:"_blank",rel:"noreferrer"},(e=>{try{const t=new URL(e);return decodeURIComponent(t.pathname)||"/"}catch{return e}})(e.page)):(0,l.createElement)("span",{className:"dms-muted"},"—")),(0,l.createElement)("td",{title:t.hint},(0,l.createElement)(h,{tone:t.tone},t.label)),(0,l.createElement)("td",{className:"dms-small dms-muted",title:new Date(e.submitted_at).toLocaleString(c)},p(e.submitted_at)))}))),b&&P>1&&(0,l.createElement)("div",{className:"dms-pager"},(0,l.createElement)("span",{className:"dms-muted dms-small"},(0,i.sprintf)(/* translators: %s: number of entries. */ /* translators: %s: number of entries. */14 (0,i._n)("%s new entry is on its way to DigiMail.","%s new entries are on their way to DigiMail.",e.capture.pending,"digimail-smtp"),o(e.capture.pending))),N&&(0,l.createElement)("p",{className:"dms-error"},N),!b&&!N&&(0,l.createElement)("div",{className:"dms-skel",style:{height:320}}),b&&0===b.entries.length&&(0,l.createElement)(k,{icon:(0,l.createElement)(w,{name:"users",size:26}),title:m||n?(0,i.__)("No matching entries","digimail-smtp"):(0,i.__)("No form entries yet","digimail-smtp")},m||n?(0,i.__)("Try another filter.","digimail-smtp"):(0,i.__)("When someone fills in a form or places an order, they show up here with the form and page they used.","digimail-smtp")),b&&b.entries.length>0&&(0,l.createElement)("table",{className:"dms-table"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Customer","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Phone","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Form","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Page","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Result","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Time","digimail-smtp")))),(0,l.createElement)("tbody",null,b.entries.map(e=>{const t=q[e.outcome];return(0,l.createElement)("tr",{key:e.id},(0,l.createElement)("td",{className:"dms-ellipsis"},(0,l.createElement)("strong",null,e.name||e.email),e.name&&(0,l.createElement)("div",{className:"dms-small dms-muted dms-ellipsis"},e.email),e.company&&(0,l.createElement)("div",{className:"dms-small dms-muted dms-ellipsis"},e.company)),(0,l.createElement)("td",{className:"dms-small"},e.phone?(0,l.createElement)("a",{href:`tel:${e.phone.replace(/[^\d+]/g,"")}`},e.phone):(0,l.createElement)("span",{className:"dms-muted"},"—")),(0,l.createElement)("td",{className:"dms-small dms-ellipsis"},R(e)),(0,l.createElement)("td",{className:"dms-small dms-ellipsis"},e.page?(0,l.createElement)("a",{href:e.page,target:"_blank",rel:"noreferrer"},(e=>{try{const t=new URL(e);return decodeURIComponent(t.pathname)||"/"}catch{return e}})(e.page)):(0,l.createElement)("span",{className:"dms-muted"},"—")),(0,l.createElement)("td",{title:t.hint},(0,l.createElement)(h,{tone:t.tone},t.label)),(0,l.createElement)("td",{className:"dms-small dms-muted",title:new Date(e.submitted_at).toLocaleString(c)},p(e.submitted_at)))}))),b&&P>1&&(0,l.createElement)("div",{className:"dms-pager"},(0,l.createElement)("span",{className:"dms-muted dms-small"},(0,i.sprintf)(/* translators: %s: number of entries. */ /* translators: %s: number of entries. */ 15 15 (0,i._n)("%s entry","%s entries",b.total,"digimail-smtp"),o(b.total))),(0,l.createElement)(f,{variant:"secondary",size:"sm",disabled:u<=1,onClick:()=>_(u-1)},(0,i.__)("Previous","digimail-smtp")),(0,l.createElement)("span",{className:"dms-small"},(0,i.sprintf)(/* translators: 1: current page, 2: number of pages. */ /* translators: 1: current page, 2: number of pages. */ 16 16 (0,i.__)("Page %1$d of %2$d","digimail-smtp"),u,P)),(0,l.createElement)(f,{variant:"secondary",size:"sm",disabled:u>=P,onClick:()=>_(u+1)},(0,i.__)("Next","digimail-smtp")))))}function V({state:e,go:t}){const[a,n]=(0,l.useState)(e.site.user_email),[s,m]=(0,l.useState)("html"),[r,c]=(0,l.useState)(!1),[o,p]=(0,l.useState)(null),[u,g]=(0,l.useState)("");return(0,l.createElement)("div",{className:"dms-grid-main"},(0,l.createElement)(E,{title:(0,i.__)("Send a test email","digimail-smtp")},e.interceptors.length>0&&(0,l.createElement)(v,{tone:"bad",title:(0,i.sprintf)(/* translators: %s: plugin names. */ /* translators: %s: plugin names. */(0,i.__)("%s is taking over wp_mail()","digimail-smtp"),e.interceptors.join(", "))},(0,i.__)("Your website’s emails stop at that plugin and never reach DigiMail. Deactivate it on the Plugins page.","digimail-smtp")),(0,l.createElement)("form",{className:"dms-form",onSubmit:e=>{e.preventDefault(),(async()=>{c(!0),g(""),p(null);try{p(await d("test",{to:a,format:s}))}catch(e){g(e.message)}finally{c(!1)}})()}},(0,l.createElement)("p",{className:"dms-muted"},(0,i.__)("The test goes through the same wp_mail() function your website and plugins use, so if it works, order emails and contact forms work too.","digimail-smtp")),(0,l.createElement)(y,{label:(0,i.__)("Send to","digimail-smtp"),htmlFor:"dms-to"},(0,l.createElement)("input",{id:"dms-to",type:"email",required:!0,value:a,onChange:e=>n(e.target.value)})),(0,l.createElement)("div",{className:"dms-field"},(0,l.createElement)("span",{className:"dms-label"},(0,i.__)("Format","digimail-smtp")),(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:"html"===s?"is-on":"",onClick:()=>m("html")},"HTML"),(0,l.createElement)("button",{type:"button",className:"text"===s?"is-on":"",onClick:()=>m("text")},(0,i.__)("Plain text","digimail-smtp")))),(0,l.createElement)("div",null,(0,l.createElement)(f,{type:"submit",busy:r},(0,l.createElement)(w,{name:"send",size:16})," ",(0,i.__)("Send test email","digimail-smtp")))),o&&(0,l.createElement)(v,{tone:"ok",title:"backup"===o.via?(0,i.__)("Sent through the backup server","digimail-smtp"):(0,i.__)("Sent. Check your inbox.","digimail-smtp"),action:"digimail"===o.via&&(0,l.createElement)(f,{variant:"secondary",size:"sm",onClick:()=>t("logs")},(0,i.__)("See status","digimail-smtp"))},(0,i.sprintf)(/* translators: 1: sender name, 2: sender email, 3: seconds taken. */ /* translators: 1: sender name, 2: sender email, 3: seconds taken. */ … … 22 22 (0,i.__)("%1$s contacts added so far, last sync %2$s.","digimail-smtp"),o(_.total??0),p(new Date(1e3*_.at).toISOString())):(0,i.__)("No contacts yet. They show up a few seconds after someone submits a form.","digimail-smtp"),k>0&&(0,l.createElement)(l.Fragment,null," ",(0,i.sprintf)(/* translators: %s: number of contacts. */ /* translators: %s: number of contacts. */(0,i.__)("%s waiting to be sent.","digimail-smtp"),o(k)))),k>0&&(0,l.createElement)(f,{size:"sm",variant:"secondary",busy:"sync"===u,onClick:async()=>{g("sync");try{const e=await d("contacts/sync",{});w(e.pending),v(e.last),e.last?.error?n(e.last.error,"bad"):n((0,i.__)("Contacts sent to DigiMail.","digimail-smtp"))}catch(e){n(e.message,"bad")}finally{g(null)}}},(0,i.__)("Send now","digimail-smtp"))),(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("Send marketing email only to people who agreed to receive it. Add an “I agree to receive news” checkbox to your forms.","digimail-smtp")))))}const G={ok:{label:(0,i.__)("Correct","digimail-smtp"),tone:"ok"},missing:{label:(0,i.__)("Not added yet","digimail-smtp"),tone:"wait"},wrong:{label:(0,i.__)("Wrong value","digimail-smtp"),tone:"bad"},unknown:{label:(0,i.__)("Could not check","digimail-smtp"),tone:"muted"}};function H({text:e,label:t}){const a=C();return(0,l.createElement)("button",{type:"button",className:"dms-copy",title:(0,i.__)("Copy","digimail-smtp"),"aria-label":(0,i.sprintf)(/* translators: %s: what is copied. */ /* translators: %s: what is copied. */(0,i.__)("Copy %s","digimail-smtp"),t),onClick:async()=>a(await async function(e){try{return await navigator.clipboard.writeText(e),!0}catch{const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();const a=document.execCommand("copy");return t.remove(),a}}(e)?(0,i.__)("Copied.","digimail-smtp"):(0,i.__)("Could not copy. Select the text and copy it by hand.","digimail-smtp"))},(0,l.createElement)("code",null,e),(0,l.createElement)(w,{name:"copy",size:14}))}function K({state:e,setState:t}){const a=C(),[n,s]=(0,l.useState)(null),[m,r]=(0,l.useState)(""),[c,p]=(0,l.useState)(""),[u,g]=(0,l.useState)(""),[_,b]=(0,l.useState)(""),k=(0,l.useCallback)(()=>d("domain").then(e=>(s(e),r(""),e)).catch(e=>(r(e.message),null)),[]);(0,l.useEffect)(()=>{k()},[k]);const N="pending"===n?.state;(0,l.useEffect)(()=>{if(!N)return;let e=0;const t=setInterval(()=>{e++,e>20||document.hidden?e>20&&clearInterval(t):k()},3e4);return()=>clearInterval(t)},[N,k]);const S="verified"===n?.state;(0,l.useEffect)(()=>{S&&"shared"===e.status.sender?.mode&&d("state?refresh=1").then(t).catch(()=>{})},[S,e.status.sender?.mode,t]);const M=async(e,t,l={})=>{p(e);try{const e=await d(t,l);return s(e),e}catch(e){return a(e.message,"bad"),null}finally{p("")}},T=async()=>{const e=await M("cf","domain/cloudflare",{token:u});e?.applied&&(g(""),a(e.applied.problems>0?(0,i.sprintf)(/* translators: %s: number of records. */ /* translators: %s: number of records. */(0,i.__)("Added what could be added. %s records need a look: see the list.","digimail-smtp"),o(e.applied.problems)):(0,i.__)("Records added in Cloudflare. Verification usually finishes within a few minutes.","digimail-smtp")))},D=n?"verified"===n.state?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("Verified","digimail-smtp")):"pending"===n.state?(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Waiting for DNS","digimail-smtp")):"failed"===n.state?(0,l.createElement)(h,{tone:"bad"},(0,i.__)("Not verified","digimail-smtp")):(0,l.createElement)(h,null,(0,i.__)("Shared address","digimail-smtp")):null,x=n?.dns?.zone??n?.zone??null,z="cloudflare"===x?.provider.key||(n?.dns?.cloudflare.can_apply??n?.can_apply??!1),$=n?.dns?.cloudflare.can_apply??n?.can_apply??!1,P=n?.dns?.cloudflare.token_url??n?.token_url??"",F=n&&x&&x.apex!==n.domain&&n.domain.endsWith(`.${x.apex}`)?[n.domain,x.apex]:null;return(0,l.createElement)(E,{title:(0,l.createElement)("span",{id:"dms-domain"},(0,i.__)("Sending domain","digimail-smtp")),aside:D},m&&(0,l.createElement)("p",{className:"dms-error"},m),!n&&!m&&(0,l.createElement)("div",{className:"dms-skel",style:{height:120}}),n&&!n.eligible&&(0,l.createElement)("p",{className:"dms-muted dms-small"},(0,i.__)("This website runs on an IP address or localhost, so it has no domain to verify. It keeps sending from the shared address.","digimail-smtp")),n?.eligible&&"taken"===n.state&&(0,l.createElement)(v,{tone:"wait",title:(0,i.sprintf)(/* translators: %s: domain. */ /* translators: %s: domain. */(0,i.__)("%s is already in another DigiMail account","digimail-smtp"),n.domain)},(0,i.__)("Log in to that account on digimail.vn, or contact DigiMail if you own this domain.","digimail-smtp")),n?.eligible&&"none"===n.state&&(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)("p",null,(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: 1: shared address, 2: example address on the site's domain. */ /* translators: 1: shared address, 2: example address on the site's domain. */ 23 23 (0,i.__)("The website sends from <code>%1$s</code>. Verify your domain to send from an address like <code>%2$s</code>: Gmail and Outlook trust it more, emails land in the inbox more often, and the shared address’s daily limit no longer applies.","digimail-smtp"),n.sender?.email??"",`noreply@${_||n.domain}`),{code:(0,l.createElement)("code",null)})),F&&(0,l.createElement)(y,{label:(0,i.__)("Domain to verify","digimail-smtp"),htmlFor:"dms-domain-pick",hint:(0,i.__)("Verifying the main domain covers every subdomain of it.","digimail-smtp")},(0,l.createElement)("select",{id:"dms-domain-pick",value:_||F[0],onChange:e=>b(e.target.value)},F.map(e=>(0,l.createElement)("option",{key:e,value:e},e)))),x&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: 1: domain, 2: DNS provider. */ /* translators: 1: domain, 2: DNS provider. */(0,i.__)("DNS of <strong>%1$s</strong> is managed at <strong>%2$s</strong>.","digimail-smtp"),x.apex,x.provider.name),{strong:(0,l.createElement)("strong",null)}),z&&(0,l.createElement)(l.Fragment,null," ",(0,i.__)("You can add the records with one click through Cloudflare.","digimail-smtp"))),(0,l.createElement)("div",null,(0,l.createElement)(f,{busy:"add"===c,onClick:()=>M("add","domain/add",_?{domain:_}:{})},(0,i.sprintf)(/* translators: %s: domain name. */ /* translators: %s: domain name. */(0,i.__)("Verify %s","digimail-smtp"),_||n.domain)))),n?.eligible&&"verified"===n.state&&(0,l.createElement)(v,{tone:"ok",title:(0,i.sprintf)(/* translators: %s: domain. */ /* translators: %s: domain. */(0,i.__)("%s is verified","digimail-smtp"),n.dns?.domain??n.domain)},"domain"===n.sender?.mode?(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: %s: sender address. */ /* translators: %s: sender address. */(0,i.__)("The website sends from <code>%s</code>.","digimail-smtp"),n.sender.email),{code:(0,l.createElement)("code",null)}):(0,i.__)("The website switches to your domain within a minute.","digimail-smtp")),n?.eligible&&("pending"===n.state||"failed"===n.state)&&n.dns&&(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)("p",{className:"dms-small"},(0,i.sprintf)(/* translators: 1: correct records, 2: required records. */ /* translators: 1: correct records, 2: required records. */ 24 (0,i.__)("%1$s of %2$s required DNS records are correct.","digimail-smtp"),o(n.dns.summary.ok_required),o(n.dns.summary.required))," ",n.dns.summary.dns_ready?(0,i.__)("DNS is ready: DigiMail confirms the domain within a few minutes, then the website switches to it by itself.","digimail-smtp"):(0,i.__)("Add the records below where your domain’s DNS is managed. Changes usually show within minutes, sometimes a few hours.","digimail-smtp")),z&&!n.dns.summary.dns_ready&&(0,l.createElement)("div",{className:"dms-cf"},(0,l.createElement)("strong",null,(0,i.__)("Add them automatically through Cloudflare","digimail-smtp")),$?(0,l.createElement)("div",null,(0,l.createElement)(f,{busy:"cf"===c,onClick:T},(0,i.__)("Add records in Cloudflare","digimail-smtp"))):(0,l.createElement)(l.Fragment,null,(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,l.createInterpolateElement)((0,i.__)("<a>Create a Cloudflare API token</a> (the link fills in the right permissions: Zone Read, DNS Edit), then paste it here. DigiMail stores it encrypted and only uses it to add these records.","digimail-smtp"),{a:(0,l.createElement)("a",{href:P,target:"_blank",rel:"noreferrer"})})),(0,l.createElement)("div",{className:"dms-row"},(0,l.createElement)("input",{type:"password",autoComplete:"off",value:u,onChange:e=>g(e.target.value),placeholder:(0,i.__)("Cloudflare API token","digimail-smtp"),"aria-label":(0,i.__)("Cloudflare API token","digimail-smtp")}),(0,l.createElement)(f,{busy:"cf"===c,disabled:u.trim().length<20,onClick:T},(0,i.__)("Connect and add records","digimail-smtp"))))),x&&!z&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: 1: DNS provider, 2: how to add records there. */ /* translators: 1: DNS provider, 2: how to add records there. */(0,i.__)("DNS is at <strong>%1$s</strong>. %2$s","digimail-smtp"),x.provider.name,x.provider.guide),{strong:(0,l.createElement)("strong",null)}),x.provider.url&&(0,l.createElement)(l.Fragment,null," ",(0,l.createElement)("a",{href:x.provider.url,target:"_blank",rel:"noreferrer"},(0,i.__)("Open","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:12})))),n.applied&&n.applied.problems>0&&(0,l.createElement)(v,{tone:"wait",title:(0,i.__)("Some records were left alone in Cloudflare","digimail-smtp")},(0,l.createElement)("ul",{className:"dms-reasons"},n.applied.outcomes.filter(e=>"conflict"===e.action||"failed"===e.action).map(e=>(0,l.createElement)("li",{key:e.name+e.type},e.type," ",e.name,": ",e.message)))),(0,l.createElement)("div",{className:"dms-table-wrap"},(0,l.createElement)("table",{className:"dms-table dms-dns"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Type","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Name (host)","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Value","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Status","digimail-smtp")))),(0,l.createElement)("tbody",null,n.dns.records.map(e=>(0,l.createElement)("tr",{key:e.type+e.name+e.value},(0,l.createElement)("td",null,(0,l.createElement)("strong",null,e.type),!e.required&&(0,l.createElement)("div",{className:"dms-small dms-muted"},(0,i.__)("recommended","digimail-smtp"))),(0,l.createElement)("td",null,(0,l.createElement)(H,{text:e.host||"@",label:(0,i.__)("name","digimail-smtp")})),(0,l.createElement)("td",null,(0,l.createElement)(H,{text:e.value,label:(0,i.__)("value","digimail-smtp")}),null!==e.priority&&(0,l.createElement)("div",{className:"dms-small dms-muted"},(0,i.sprintf)(/* translators: %s: MX priority. */ /* translators: %s: MX priority. */(0,i.__)("Priority: %s","digimail-smtp"),e.priority)),"CNAME"===e.type&&z&&(0,l.createElement)("div",{className:"dms-small dms-muted"},(0,i.__)("Proxy off (DNS only)","digimail-smtp"))),(0,l.createElement)("td",null,(0,l.createElement)(h,{tone:G[e.state].tone},G[e.state].label),"ok"!==e.state&&e.note&&(0,l.createElement)("div",{className:"dms-small dms-muted"},e.note))))))),(0,l.createElement)("div",{className:"dms-actions"},(0,l.createElement)(f,{busy:"check"===c,onClick:()=>M("check","domain/check")},(0,l.createElement)(w,{name:"refresh",size:15})," ",(0,i.__)("Check again","digimail-smtp")),(0,l.createElement)(f,{variant:"secondary",busy:"zone"===c,onClick:async()=>{p("zone");try{const e=await d("domain/zonefile"),t=URL.createObjectURL(new Blob([e.text],{type:"text/plain;charset=utf-8"})),a=document.createElement("a");a.href=t,a.download=`digimail-${n?.dns?.domain??"dns"}.txt`,a.click(),URL.revokeObjectURL(t)}catch(e){a(e.message,"bad")}finally{p("")}}},(0,l.createElement)(w,{name:"download",size:15})," ",(0,i.__)("Download zone file","digimail-smtp"))),(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("When the domain is verified, DigiMail tells you by Telegram or email (see Alerts).","digimail-smtp"))))}const Y={bad:"bad",warn:"wait",good:"ok"};function J(){const e=C(),[t,a]=(0,l.useState)(null),[n,s]=(0,l.useState)(""),[m,r]=(0,l.useState)(""),[c,u]=(0,l.useState)(null),g=(0,l.useRef)(null),_=(0,l.useCallback)(()=>d("alerts").then(e=>(a(e),s(""),e)).catch(e=>(s(e.message),null)),[]);(0,l.useEffect)(()=>(_(),()=>{g.current&&clearInterval(g.current)}),[_]);const y=async t=>{r("prefs");try{a(await d("alerts/prefs",t))}catch(t){e(t.message,"bad")}finally{r("")}},v=t?.telegram.chats??[],k=!!t&&(t.prefs.telegram&&v.length>0||t.prefs.email&&t.emails.length>0);return(0,l.createElement)(E,{title:(0,i.__)("Alerts","digimail-smtp"),aside:t?k?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("On","digimail-smtp")):(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Off","digimail-smtp")):null},n&&(0,l.createElement)("p",{className:"dms-error"},n),!t&&!n&&(0,l.createElement)("div",{className:"dms-skel",style:{height:120}}),t&&(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("DigiMail tells you when emails fail, the quota is nearly used up, bounces or spam reports rise, the plugin stops reporting, forms are hit by bots, or something changes with your domain. The same problem is repeated at most once a day.","digimail-smtp")),(0,l.createElement)(b,{checked:t.prefs.telegram,disabled:"prefs"===m||!t.telegram.available,onChange:e=>y({...t.prefs,telegram:e}),label:(0,i.__)("Telegram","digimail-smtp"),hint:t.telegram.available?v.length?(0,i.sprintf)(/* translators: %s: number of chats. */ /* translators: %s: number of chats. */(0,i._n)("Sent to %s connected chat.","Sent to %s connected chats.",v.length,"digimail-smtp"),o(v.length)):(0,i.sprintf)(/* translators: %s: bot username. */ /* translators: %s: bot username. */(0,i.__)("Connect your Telegram (or a group) to the %s bot.","digimail-smtp"),t.telegram.bot??""):(0,i.__)("Telegram alerts are not available yet.","digimail-smtp")}),t.telegram.available&&(0,l.createElement)("div",{className:"dms-chats"},v.map(t=>(0,l.createElement)("div",{key:t.id,className:"dms-chat"},(0,l.createElement)(w,{name:"private"===t.kind?"send":"users",size:15}),(0,l.createElement)("span",{className:"dms-grow"},t.title,"private"!==t.kind&&(0,l.createElement)("span",{className:"dms-muted dms-small"}," · ",(0,i.__)("group","digimail-smtp"))),(0,l.createElement)(f,{size:"sm",variant:"ghost",busy:m===t.id,onClick:()=>(async t=>{r(t.id);try{a(await d("alerts/telegram/remove",{id:t.id}))}catch(t){e(t.message,"bad")}finally{r("")}})(t)},(0,i.__)("Remove","digimail-smtp")))),(0,l.createElement)("div",{className:"dms-actions"},(0,l.createElement)(f,{size:"sm",busy:"link"===m,onClick:async()=>{r("link");try{const a=await d("alerts/telegram",{});u(a),window.open(a.start_url,"_blank","noopener");const l=t?.telegram.chats.length??0;let n=0;g.current&&clearInterval(g.current),g.current=setInterval(async()=>{n++;const t=await _();(t&&t.telegram.chats.length>l||n>40)&&(g.current&&clearInterval(g.current),t&&t.telegram.chats.length>l&&(u(null),e((0,i.__)("Telegram connected.","digimail-smtp"))))},3e3)}catch(t){e(t.message,"bad")}finally{r("")}}},v.length?(0,i.__)("Connect another Telegram","digimail-smtp"):(0,i.__)("Connect Telegram","digimail-smtp"))),c&&(0,l.createElement)("div",{className:"dms-cf"},(0,l.createElement)("strong",null,(0,i.__)("Finish in Telegram","digimail-smtp")),(0,l.createElement)("span",{className:"dms-small"},(0,i.sprintf)(/* translators: %s: bot username. */ /* translators: %s: bot username. */(0,i.__)("Telegram opens a chat with %s: press Start. This page updates by itself once it is connected.","digimail-smtp"),c.bot)),(0,l.createElement)("div",{className:"dms-actions"},(0,l.createElement)("a",{className:"dms-btn dms-btn-secondary dms-btn-sm",href:c.start_url,target:"_blank",rel:"noreferrer"},(0,i.__)("Open Telegram","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:13})),(0,l.createElement)("a",{className:"dms-btn dms-btn-ghost dms-btn-sm",href:c.group_url,target:"_blank",rel:"noreferrer"},(0,i.__)("Add to a group instead","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:13}))),(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,i.__)("The link works once and expires in 30 minutes.","digimail-smtp")))),(0,l.createElement)(b,{checked:t.prefs.email,disabled:"prefs"===m,onChange:e=>y({...t.prefs,email:e}),label:(0,i.__)("Email","digimail-smtp"),hint:(0,i.sprintf)(/* translators: %s: email addresses. */ /* translators: %s: email addresses. */(0,i.__)("To %s (the users of your DigiMail account).","digimail-smtp"),t.emails.join(", "))}), (0,l.createElement)("div",null,(0,l.createElement)(f,{variant:"secondary",size:"sm",busy:"test"===m,disabled:!k,onClick:async()=>{r("test");try{const t=await d("alerts/test",{});e(t.telegram+t.email>0?(0,i.sprintf)(/* translators: 1: Telegram chats, 2: email addresses. */ /* translators: 1: Telegram chats, 2: email addresses. */(0,i.__)("Test alert sent: %1$s Telegram, %2$s email.","digimail-smtp"),o(t.telegram),o(t.email)):(0,i.__)("Nothing was sent: turn on email or connect Telegram first.","digimail-smtp"),t.telegram+t.email>0?"ok":"bad"),_()}catch(t){e(t.message,"bad")}finally{r("")}}},(0,l.createElement)(w,{name:"bell",size:14})," ",(0,i.__)("Send a test alert","digimail-smtp"))),t.recent.length>0&&(0,l.createElement)("div",{className:"dms-recent"},(0,l.createElement)("strong",{className:"dms-small"},(0,i.__)("Recent alerts","digimail-smtp")),(0,l.createElement)("ul",null,t.recent.slice(0,5).map(e=>(0,l.createElement)("li",{key:e.created_at+e.kind,title:e.body},(0,l.createElement)(h,{tone:Y[e.level]},p(e.created_at))," ",e.title))))))}function Q({state:e,setState:t}){const a=C(),[n,s]=(0,l.useState)(e.settings),[m,r]=(0,l.useState)(null),c=e.status.sender,o=c?.verified_domains??[],[p,u]=(0,l.useState)("domain"===c?.mode?c.email:""),[g,_]=(0,l.useState)(e.site.user_email),k=JSON.stringify(n)!==JSON.stringify(e.settings),N=async(e,l=(0,i.__)("Settings saved.","digimail-smtp"))=>{r("save");try{const i=await d("settings",e??n);return t(i),s(i.settings),a(l),!0}catch(e){return a(e.message,"bad"),!1}finally{r(null)}},S=Object.entries(e.controls).reduce((e,[t,a])=>((e[a.group]=e[a.group]??[]).push([t,a]),e),{}),M=n.backup,T=e=>s({...n,backup:{...M,...e}});return(0,l.createElement)("div",{className:"dms-grid-main"},(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)(E,{title:(0,i.__)("Sender","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(y,{label:(0,i.__)("Sender name","digimail-smtp"),htmlFor:"dms-name",hint:(0,i.__)("Leave empty to use the website name. Recipients see this name in their inbox.","digimail-smtp")},(0,l.createElement)("input",{id:"dms-name",value:n.from_name,placeholder:c?.name??e.site.name,onChange:e=>s({...n,from_name:e.target.value})})),(0,l.createElement)(b,{checked:n.force_from_name,onChange:e=>s({...n,force_from_name:e}),label:(0,i.__)("Always use this name","digimail-smtp"),hint:(0,i.__)("Even when another plugin (WooCommerce, a contact form) sets its own sender name.","digimail-smtp")}),(0,l.createElement)(y,{label:(0,i.__)("Sender email","digimail-smtp"),htmlFor:"dms-from",hint:o.length?(0,i.__)("Only addresses on domains verified in DigiMail can be used.","digimail-smtp"):(0,i.__)("Verify your domain on digimail.vn to send from your company email.","digimail-smtp")},o.length?(0,l.createElement)("select",{id:"dms-from",value:p,onChange:e=>u(e.target.value)},(0,l.createElement)("option",{value:""},(0,i.sprintf)(/* translators: %s: email address chosen automatically. */ /* translators: %s: email address chosen automatically. */24 (0,i.__)("%1$s of %2$s required DNS records are correct.","digimail-smtp"),o(n.dns.summary.ok_required),o(n.dns.summary.required))," ",n.dns.summary.dns_ready?(0,i.__)("DNS is ready: DigiMail confirms the domain within a few minutes, then the website switches to it by itself.","digimail-smtp"):(0,i.__)("Add the records below where your domain’s DNS is managed. Changes usually show within minutes, sometimes a few hours.","digimail-smtp")),z&&!n.dns.summary.dns_ready&&(0,l.createElement)("div",{className:"dms-cf"},(0,l.createElement)("strong",null,(0,i.__)("Add them automatically through Cloudflare","digimail-smtp")),$?(0,l.createElement)("div",null,(0,l.createElement)(f,{busy:"cf"===c,onClick:T},(0,i.__)("Add records in Cloudflare","digimail-smtp"))):(0,l.createElement)(l.Fragment,null,(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,l.createInterpolateElement)((0,i.__)("<a>Create a Cloudflare API token</a> (the link fills in the right permissions: Zone Read, DNS Edit), then paste it here. DigiMail stores it encrypted and only uses it to add these records.","digimail-smtp"),{a:(0,l.createElement)("a",{href:P,target:"_blank",rel:"noreferrer"})})),(0,l.createElement)("div",{className:"dms-row"},(0,l.createElement)("input",{type:"password",autoComplete:"off",value:u,onChange:e=>g(e.target.value),placeholder:(0,i.__)("Cloudflare API token","digimail-smtp"),"aria-label":(0,i.__)("Cloudflare API token","digimail-smtp")}),(0,l.createElement)(f,{busy:"cf"===c,disabled:u.trim().length<20,onClick:T},(0,i.__)("Connect and add records","digimail-smtp"))))),x&&!z&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: 1: DNS provider, 2: how to add records there. */ /* translators: 1: DNS provider, 2: how to add records there. */(0,i.__)("DNS is at <strong>%1$s</strong>. %2$s","digimail-smtp"),x.provider.name,x.provider.guide),{strong:(0,l.createElement)("strong",null)}),x.provider.url&&(0,l.createElement)(l.Fragment,null," ",(0,l.createElement)("a",{href:x.provider.url,target:"_blank",rel:"noreferrer"},(0,i.__)("Open","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:12})))),n.applied&&n.applied.problems>0&&(0,l.createElement)(v,{tone:"wait",title:(0,i.__)("Some records were left alone in Cloudflare","digimail-smtp")},(0,l.createElement)("ul",{className:"dms-reasons"},n.applied.outcomes.filter(e=>"conflict"===e.action||"failed"===e.action).map(e=>(0,l.createElement)("li",{key:e.name+e.type},e.type," ",e.name,": ",e.message)))),(0,l.createElement)("div",{className:"dms-table-wrap"},(0,l.createElement)("table",{className:"dms-table dms-dns"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Type","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Name (host)","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Value","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Status","digimail-smtp")))),(0,l.createElement)("tbody",null,n.dns.records.map(e=>(0,l.createElement)("tr",{key:e.type+e.name+e.value},(0,l.createElement)("td",null,(0,l.createElement)("strong",null,e.type),!e.required&&(0,l.createElement)("div",{className:"dms-small dms-muted"},(0,i.__)("recommended","digimail-smtp"))),(0,l.createElement)("td",null,(0,l.createElement)(H,{text:e.host||"@",label:(0,i.__)("name","digimail-smtp")})),(0,l.createElement)("td",null,(0,l.createElement)(H,{text:e.value,label:(0,i.__)("value","digimail-smtp")}),null!==e.priority&&(0,l.createElement)("div",{className:"dms-small dms-muted"},(0,i.sprintf)(/* translators: %s: MX priority. */ /* translators: %s: MX priority. */(0,i.__)("Priority: %s","digimail-smtp"),e.priority)),"CNAME"===e.type&&z&&(0,l.createElement)("div",{className:"dms-small dms-muted"},(0,i.__)("Proxy off (DNS only)","digimail-smtp"))),(0,l.createElement)("td",null,(0,l.createElement)(h,{tone:G[e.state].tone},G[e.state].label),"ok"!==e.state&&e.note&&(0,l.createElement)("div",{className:"dms-small dms-muted"},e.note))))))),(0,l.createElement)("div",{className:"dms-actions"},(0,l.createElement)(f,{busy:"check"===c,onClick:()=>M("check","domain/check")},(0,l.createElement)(w,{name:"refresh",size:15})," ",(0,i.__)("Check again","digimail-smtp")),(0,l.createElement)(f,{variant:"secondary",busy:"zone"===c,onClick:async()=>{p("zone");try{const e=await d("domain/zonefile"),t=URL.createObjectURL(new Blob([e.text],{type:"text/plain;charset=utf-8"})),a=document.createElement("a");a.href=t,a.download=`digimail-${n?.dns?.domain??"dns"}.txt`,a.click(),URL.revokeObjectURL(t)}catch(e){a(e.message,"bad")}finally{p("")}}},(0,l.createElement)(w,{name:"download",size:15})," ",(0,i.__)("Download zone file","digimail-smtp"))),(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("When the domain is verified, DigiMail tells you by Telegram or email (see Alerts).","digimail-smtp"))))}const Y={bad:"bad",warn:"wait",good:"ok"};function J(){const e=C(),[t,a]=(0,l.useState)(null),[n,s]=(0,l.useState)(""),[m,r]=(0,l.useState)(""),[c,u]=(0,l.useState)(null),g=(0,l.useRef)(null),_=(0,l.useCallback)(()=>d("alerts").then(e=>(a(e),s(""),e)).catch(e=>(s(e.message),null)),[]);(0,l.useEffect)(()=>(_(),()=>{g.current&&clearInterval(g.current)}),[_]);const y=async t=>{r("prefs");try{a(await d("alerts/prefs",t))}catch(t){e(t.message,"bad")}finally{r("")}},v=t?.telegram.chats??[],k=!!t&&(t.prefs.telegram&&v.length>0||t.prefs.email&&t.emails.length>0);return(0,l.createElement)(E,{title:(0,i.__)("Alerts","digimail-smtp"),aside:t?k?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("On","digimail-smtp")):(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Off","digimail-smtp")):null},n&&(0,l.createElement)("p",{className:"dms-error"},n),!t&&!n&&(0,l.createElement)("div",{className:"dms-skel",style:{height:120}}),t&&(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("DigiMail tells you when emails fail, the quota is nearly used up, bounces or spam reports rise, the plugin stops reporting, forms are hit by bots, or something changes with your domain. The same problem is repeated at most once a day.","digimail-smtp")),(0,l.createElement)(b,{checked:t.prefs.telegram,disabled:"prefs"===m||!t.telegram.available,onChange:e=>y({...t.prefs,telegram:e}),label:(0,i.__)("Telegram","digimail-smtp"),hint:t.telegram.available?v.length?(0,i.sprintf)(/* translators: %s: number of chats. */ /* translators: %s: number of chats. */(0,i._n)("Sent to %s connected chat.","Sent to %s connected chats.",v.length,"digimail-smtp"),o(v.length)):(0,i.sprintf)(/* translators: %s: bot username. */ /* translators: %s: bot username. */(0,i.__)("Connect your Telegram (or a group) to the %s bot.","digimail-smtp"),t.telegram.bot??""):(0,i.__)("Telegram alerts are not available yet.","digimail-smtp")}),t.telegram.available&&(0,l.createElement)("div",{className:"dms-chats"},v.map(t=>(0,l.createElement)("div",{key:t.id,className:"dms-chat"},(0,l.createElement)(w,{name:"private"===t.kind?"send":"users",size:15}),(0,l.createElement)("span",{className:"dms-grow"},t.title,"private"!==t.kind&&(0,l.createElement)("span",{className:"dms-muted dms-small"}," · ",(0,i.__)("group","digimail-smtp"))),(0,l.createElement)(f,{size:"sm",variant:"ghost",busy:m===t.id,onClick:()=>(async t=>{r(t.id);try{a(await d("alerts/telegram/remove",{id:t.id}))}catch(t){e(t.message,"bad")}finally{r("")}})(t)},(0,i.__)("Remove","digimail-smtp")))),(0,l.createElement)("div",{className:"dms-actions"},(0,l.createElement)(f,{size:"sm",busy:"link"===m,onClick:async()=>{r("link");try{const a=await d("alerts/telegram",{});u(a),window.open(a.start_url,"_blank","noopener");const l=t?.telegram.chats.length??0;let n=0;g.current&&clearInterval(g.current),g.current=setInterval(async()=>{n++;const t=await _();(t&&t.telegram.chats.length>l||n>40)&&(g.current&&clearInterval(g.current),t&&t.telegram.chats.length>l&&(u(null),e((0,i.__)("Telegram connected.","digimail-smtp"))))},3e3)}catch(t){e(t.message,"bad")}finally{r("")}}},v.length?(0,i.__)("Connect another Telegram","digimail-smtp"):(0,i.__)("Connect Telegram","digimail-smtp"))),c&&(0,l.createElement)("div",{className:"dms-cf"},(0,l.createElement)("strong",null,(0,i.__)("Finish in Telegram","digimail-smtp")),(0,l.createElement)("span",{className:"dms-small"},(0,i.sprintf)(/* translators: %s: bot username. */ /* translators: %s: bot username. */(0,i.__)("Telegram opens a chat with %s: press Start. This page updates by itself once it is connected.","digimail-smtp"),c.bot)),(0,l.createElement)("div",{className:"dms-actions"},(0,l.createElement)("a",{className:"dms-btn dms-btn-secondary dms-btn-sm",href:c.start_url,target:"_blank",rel:"noreferrer"},(0,i.__)("Open Telegram","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:13})),(0,l.createElement)("a",{className:"dms-btn dms-btn-ghost dms-btn-sm",href:c.group_url,target:"_blank",rel:"noreferrer"},(0,i.__)("Add to a group instead","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:13}))),(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,i.__)("The link works once and expires in 30 minutes.","digimail-smtp")))),(0,l.createElement)(b,{checked:t.prefs.email,disabled:"prefs"===m,onChange:e=>y({...t.prefs,email:e}),label:(0,i.__)("Email","digimail-smtp"),hint:(0,i.sprintf)(/* translators: %s: email addresses. */ /* translators: %s: email addresses. */(0,i.__)("To %s (the users of your DigiMail account).","digimail-smtp"),t.emails.join(", "))}),void 0!==t.prefs.weekly&&(0,l.createElement)(b,{checked:t.prefs.weekly,disabled:"prefs"===m,onChange:e=>y({...t.prefs,weekly:e}),label:(0,i.__)("Weekly summary by email","digimail-smtp"),hint:(0,i.__)("Every Monday morning: emails sent last week, delivery rate, spam blocked on each website and the month’s quota. Nothing is sent after a quiet week.","digimail-smtp")}),(0,l.createElement)("div",null,(0,l.createElement)(f,{variant:"secondary",size:"sm",busy:"test"===m,disabled:!k,onClick:async()=>{r("test");try{const t=await d("alerts/test",{});e(t.telegram+t.email>0?(0,i.sprintf)(/* translators: 1: Telegram chats, 2: email addresses. */ /* translators: 1: Telegram chats, 2: email addresses. */(0,i.__)("Test alert sent: %1$s Telegram, %2$s email.","digimail-smtp"),o(t.telegram),o(t.email)):(0,i.__)("Nothing was sent: turn on email or connect Telegram first.","digimail-smtp"),t.telegram+t.email>0?"ok":"bad"),_()}catch(t){e(t.message,"bad")}finally{r("")}}},(0,l.createElement)(w,{name:"bell",size:14})," ",(0,i.__)("Send a test alert","digimail-smtp"))),t.recent.length>0&&(0,l.createElement)("div",{className:"dms-recent"},(0,l.createElement)("strong",{className:"dms-small"},(0,i.__)("Recent alerts","digimail-smtp")),(0,l.createElement)("ul",null,t.recent.slice(0,5).map(e=>(0,l.createElement)("li",{key:e.created_at+e.kind,title:e.body},(0,l.createElement)(h,{tone:Y[e.level]},p(e.created_at))," ",e.title))))))}function Q({state:e,setState:t}){const a=C(),[n,s]=(0,l.useState)(e.settings),[m,r]=(0,l.useState)(null),c=e.status.sender,o=c?.verified_domains??[],[p,u]=(0,l.useState)("domain"===c?.mode?c.email:""),[g,_]=(0,l.useState)(e.site.user_email),k=JSON.stringify(n)!==JSON.stringify(e.settings),N=async(e,l=(0,i.__)("Settings saved.","digimail-smtp"))=>{r("save");try{const i=await d("settings",e??n);return t(i),s(i.settings),a(l),!0}catch(e){return a(e.message,"bad"),!1}finally{r(null)}},S=Object.entries(e.controls).reduce((e,[t,a])=>((e[a.group]=e[a.group]??[]).push([t,a]),e),{}),M=n.backup,T=e=>s({...n,backup:{...M,...e}});return(0,l.createElement)("div",{className:"dms-grid-main"},(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)(E,{title:(0,i.__)("Sender","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(y,{label:(0,i.__)("Sender name","digimail-smtp"),htmlFor:"dms-name",hint:(0,i.__)("Leave empty to use the website name. Recipients see this name in their inbox.","digimail-smtp")},(0,l.createElement)("input",{id:"dms-name",value:n.from_name,placeholder:c?.name??e.site.name,onChange:e=>s({...n,from_name:e.target.value})})),(0,l.createElement)(b,{checked:n.force_from_name,onChange:e=>s({...n,force_from_name:e}),label:(0,i.__)("Always use this name","digimail-smtp"),hint:(0,i.__)("Even when another plugin (WooCommerce, a contact form) sets its own sender name.","digimail-smtp")}),(0,l.createElement)(y,{label:(0,i.__)("Sender email","digimail-smtp"),htmlFor:"dms-from",hint:o.length?(0,i.__)("Only addresses on domains verified in DigiMail can be used.","digimail-smtp"):(0,i.__)("Verify your domain on digimail.vn to send from your company email.","digimail-smtp")},o.length?(0,l.createElement)("select",{id:"dms-from",value:p,onChange:e=>u(e.target.value)},(0,l.createElement)("option",{value:""},(0,i.sprintf)(/* translators: %s: email address chosen automatically. */ /* translators: %s: email address chosen automatically. */ 25 25 (0,i.__)("Automatic (%s)","digimail-smtp"),"domain"===c?.mode?c.email:`noreply@${o[0]}`)),o.flatMap(e=>["noreply","thongbao","lienhe","hotro","donhang"].map(t=>`${t}@${e}`)).map(e=>(0,l.createElement)("option",{key:e,value:e},e)),p&&!o.flatMap(e=>["noreply","thongbao","lienhe","hotro","donhang"].map(t=>`${t}@${e}`)).includes(p)&&(0,l.createElement)("option",{value:p},p)):(0,l.createElement)("div",{className:"dms-readonly"},c?.email," ",(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Shared address","digimail-smtp")))),"shared"===c?.mode&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: %s: reply-to email address. */ /* translators: %s: reply-to email address. */(0,i.__)("Replies go to <strong>%s</strong>.","digimail-smtp"),c.reply_to??e.site.admin_email),{strong:(0,l.createElement)("strong",null)})),(0,l.createElement)("div",null,(0,l.createElement)(f,{busy:"sender"===m,onClick:async()=>{r("sender");try{const e=await d("sender",{from_email:p,from_name:n.from_name});t(e),await N({from_name:n.from_name,force_from_name:n.force_from_name},(0,i.__)("Sender saved.","digimail-smtp"))}catch(e){a(e.message,"bad")}finally{r(null)}}},(0,i.__)("Save sender","digimail-smtp"))))),(0,l.createElement)(K,{state:e,setState:t}),(0,l.createElement)(J,null),(0,l.createElement)(E,{title:(0,i.__)("Sending email","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(b,{checked:n.queue,onChange:e=>s({...n,queue:e}),label:(0,i.__)("Background sending","digimail-smtp"),hint:(0,i.__)("Checkout and contact forms do not wait for email: messages are queued and sent right after. Recommended for online shops.","digimail-smtp")}),n.queue&&!e.env.cron&&(0,l.createElement)(v,{tone:"wait"},(0,l.createInterpolateElement)((0,i.__)("WP-Cron is off (DISABLE_WP_CRON). A server cron job must call wp-cron.php every minute, or run <code>wp digimail queue</code>.","digimail-smtp"),{code:(0,l.createElement)("code",null)})))),(0,l.createElement)(A,{state:e,s:n,setS:s}),(0,l.createElement)(U,{state:e,s:n,setS:s}),(0,l.createElement)(E,{title:(0,i.__)("Backup connection","digimail-smtp"),aside:M.enabled?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("On","digimail-smtp")):(0,l.createElement)(h,null,(0,i.__)("Off","digimail-smtp"))},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)("p",{className:"dms-muted dms-small"},(0,i.__)("When DigiMail cannot send (network down, quota used up), the plugin sends through this SMTP server so no email is lost. Your hosting SMTP, Gmail or Microsoft 365 all work.","digimail-smtp")),(0,l.createElement)(b,{checked:M.enabled,onChange:e=>T({enabled:e}),label:(0,i.__)("Turn on backup connection","digimail-smtp")}),M.enabled&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("div",{className:"dms-two"},(0,l.createElement)(y,{label:(0,i.__)("SMTP server","digimail-smtp"),htmlFor:"dms-bh"},(0,l.createElement)("input",{id:"dms-bh",value:M.host,onChange:e=>T({host:e.target.value}),placeholder:"smtp.gmail.com"})),(0,l.createElement)(y,{label:(0,i.__)("Port","digimail-smtp"),htmlFor:"dms-bp"},(0,l.createElement)("input",{id:"dms-bp",type:"number",value:M.port,onChange:e=>T({port:Number(e.target.value)})}))),(0,l.createElement)("div",{className:"dms-field"},(0,l.createElement)("span",{className:"dms-label"},(0,i.__)("Encryption","digimail-smtp")),(0,l.createElement)("div",{className:"dms-seg"},[["tls","TLS (587)"],["ssl","SSL (465)"],["none",(0,i.__)("None","digimail-smtp")]].map(([e,t])=>(0,l.createElement)("button",{key:e,type:"button",className:M.encryption===e?"is-on":"",onClick:()=>T({encryption:e,port:"ssl"===e?465:"tls"===e?587:25})},t)))),(0,l.createElement)("div",{className:"dms-two"},(0,l.createElement)(y,{label:(0,i.__)("Username","digimail-smtp"),htmlFor:"dms-bu"},(0,l.createElement)("input",{id:"dms-bu",value:M.username,autoComplete:"off",onChange:e=>T({username:e.target.value})})),(0,l.createElement)(y,{label:(0,i.__)("Password","digimail-smtp"),htmlFor:"dms-bpw",hint:(0,i.__)("Encrypted when saved.","digimail-smtp")},(0,l.createElement)("input",{id:"dms-bpw",type:"password",autoComplete:"new-password",value:M.password,onChange:e=>T({password:e.target.value})}))),(0,l.createElement)(y,{label:(0,i.__)("From email on this server","digimail-smtp"),htmlFor:"dms-bf",hint:(0,i.__)("Leave empty to use the SMTP username.","digimail-smtp")},(0,l.createElement)("input",{id:"dms-bf",type:"email",value:M.from_email,onChange:e=>T({from_email:e.target.value})})),(0,l.createElement)("div",{className:"dms-inline"},(0,l.createElement)("input",{type:"email","aria-label":(0,i.__)("Send a test email to","digimail-smtp"),value:g,onChange:e=>_(e.target.value)}),(0,l.createElement)(f,{variant:"secondary",busy:"backup"===m,onClick:async()=>{if(!k||await N()){r("backup");try{await d("backup/test",{to:g}),a((0,i.sprintf)(/* translators: %s: email address. */ /* translators: %s: email address. */(0,i.__)("The backup server sent an email to %s.","digimail-smtp"),g))}catch(e){a(e.message,"bad")}finally{r(null)}}}},(0,i.__)("Save and send test","digimail-smtp")))))),(0,l.createElement)(E,{title:(0,i.__)("Turn off WordPress default emails","digimail-smtp")},(0,l.createElement)("p",{className:"dms-muted dms-small"},(0,i.__)("Fewer unneeded emails for administrators. Order emails, contact forms and password resets are not affected.","digimail-smtp")),Object.entries(S).map(([e,t])=>(0,l.createElement)("div",{key:e,className:"dms-group"},(0,l.createElement)("h3",null,e),t.map(([e,t])=>(0,l.createElement)(b,{key:e,checked:!1!==n.controls[e],onChange:t=>{const a={...n.controls};t?delete a[e]:a[e]=!1,s({...n,controls:a})},label:t.label,hint:t.hint||void 0})))))),(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)("div",{className:"dms-sticky"},(0,l.createElement)(E,{title:(0,i.__)("Save changes","digimail-smtp")},(0,l.createElement)("p",{className:"dms-muted dms-small"},k?(0,i.__)("You have unsaved changes.","digimail-smtp"):(0,i.__)("All changes are saved.","digimail-smtp")),(0,l.createElement)(f,{size:"block",busy:"save"===m,disabled:!k,onClick:()=>N()},(0,i.__)("Save settings","digimail-smtp"))),(0,l.createElement)(E,{title:(0,i.__)("Connection","digimail-smtp")},(0,l.createElement)("dl",{className:"dms-dl"},(0,l.createElement)("dt",null,(0,i.__)("Website","digimail-smtp")),(0,l.createElement)("dd",null,e.status.site?.name),(0,l.createElement)("dt",null,(0,i.__)("Account","digimail-smtp")),(0,l.createElement)("dd",null,e.status.account?.name),(0,l.createElement)("dt",null,(0,i.__)("Key","digimail-smtp")),(0,l.createElement)("dd",null,e.token_constant?(0,i.__)("Set in wp-config.php","digimail-smtp"):(0,i.__)("Stored in the database","digimail-smtp"))),(0,l.createElement)(b,{checked:n.keep_data,onChange:e=>s({...n,keep_data:e}),label:(0,i.__)("Keep settings when the plugin is deleted","digimail-smtp")}),(0,l.createElement)(b,{checked:!!n.diagnostics,onChange:e=>s({...n,diagnostics:e}),label:(0,i.__)("Share diagnostics with DigiMail support","digimail-smtp"),hint:(0,i.__)("Off by default. When on, the WordPress, PHP and WooCommerce versions, language, a few of this plugin's settings and the names of other active email plugins are sent with the twice-daily status check, so support can see problems on digimail.vn.","digimail-smtp")}),!e.token_constant&&(0,l.createElement)(f,{variant:"danger",size:"block",busy:"disconnect"===m,onClick:async()=>{window.confirm((0,i.__)("Disconnect DigiMail? The website will go back to sending email through your hosting server (or the backup server, if set).","digimail-smtp"))&&(r("disconnect"),await d("disconnect",{}),window.location.reload())}},(0,l.createElement)(w,{name:"x",size:15})," ",(0,i.__)("Disconnect DigiMail","digimail-smtp"))))))}function Z({state:e,setState:t}){const a=C(),[n,s]=(0,l.useState)(null),m=e.conflicts.map(e=>e.name),r=[`DigiMail SMTP ${e.env.plugin}`,`WordPress ${e.env.wordpress}, PHP ${e.env.php}`,`Website: ${e.site.url}`,`Connected: ${e.connected?"yes":"no"}${e.revoked?" (revoked)":""}`,`From: ${e.status.sender?.email??"-"} (${e.status.sender?.mode??"-"})`,`Background sending: ${e.settings.queue?"on":"off"}, WP-Cron: ${e.env.cron?"on":"off"}`,`Backup: ${e.settings.backup.enabled?e.settings.backup.host:"off"}`,`Queue: ${e.queue.queued} waiting, ${e.queue.failed} failed`,`Other SMTP plugins: ${m.join(", ")||"none"}`].join("\n");return(0,l.createElement)("div",{className:"dms-grid-main"},(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)(E,{title:(0,i.__)("Switch from another SMTP plugin","digimail-smtp")},(0,l.createElement)("p",{className:"dms-muted dms-small"},(0,i.__)("Imports the sender name and the emails you turned off. The old SMTP server becomes the backup connection: DigiMail sends, and the old server is used only when DigiMail cannot.","digimail-smtp")),0===e.importable.length?(0,l.createElement)(k,{title:(0,i.__)("No settings found to import","digimail-smtp")},(0,i.__)("Supports WP Mail SMTP, Easy WP SMTP, Post SMTP, FluentSMTP and SMTP Mailer.","digimail-smtp")):(0,l.createElement)("ul",{className:"dms-list"},e.importable.map(e=>(0,l.createElement)("li",{key:e.key},(0,l.createElement)("span",null,(0,l.createElement)("strong",null,e.name),m.includes(e.name)&&(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Active","digimail-smtp")),(0,l.createElement)("small",null,e.smtp?(0,i.__)("Has an SMTP server to use as backup","digimail-smtp"):(0,i.__)("Sender name only","digimail-smtp"))),(0,l.createElement)(f,{variant:"secondary",size:"sm",busy:n===e.key,onClick:()=>(async(e,l)=>{s(e);try{const n=await d("import",{from:e});t(n),a(n.settings.backup.host?(0,i.sprintf)(/* translators: %s: plugin name. */ /* translators: %s: plugin name. */(0,i.__)("Settings imported from %s. The old SMTP server is now the backup connection.","digimail-smtp"),l):(0,i.sprintf)(/* translators: %s: plugin name. */ /* translators: %s: plugin name. */(0,i.__)("Settings imported from %s.","digimail-smtp"),l))}catch(e){a(e.message,"bad")}finally{s(null)}})(e.key,e.name)},(0,i.__)("Import","digimail-smtp"))))),m.length>0&&(0,l.createElement)("p",{className:"dms-small"},(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: %s: plugin names. */ /* translators: %s: plugin names. */(0,i.__)("After importing, deactivate %s on the <a>Plugins page</a> so the two plugins do not both try to send email.","digimail-smtp"),m.join(", ")),{a:(0,l.createElement)("a",{href:"plugins.php"})}))),(0,l.createElement)(E,{title:(0,i.__)("Command line (WP-CLI)","digimail-smtp")},(0,l.createElement)("pre",{className:"dms-pre"},[`wp digimail status # ${(0,i.__)("connection, sender, quota","digimail-smtp")}`,`wp digimail test you@company.com # ${(0,i.__)("send a test email","digimail-smtp")}`,`wp digimail queue --retry-failed # ${(0,i.__)("resend waiting and failed emails","digimail-smtp")}`,"wp digimail connect you@company.com","wp digimail disconnect"].join("\n")),(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("Agencies can set the key in wp-config.php:","digimail-smtp")," ",(0,l.createElement)("code",null,"define( 'DIGIMAIL_SMTP_TOKEN', 'dm_…' );")))),(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)(E,{title:(0,i.__)("Support information","digimail-smtp"),aside:(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:()=>{navigator.clipboard?.writeText(r),a((0,i.__)("Copied.","digimail-smtp"))}},(0,l.createElement)(w,{name:"download",size:14})," ",(0,i.__)("Copy","digimail-smtp"))},(0,l.createElement)("pre",{className:"dms-pre"},r),(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("Send this when you contact DigiMail support. It contains no secret keys.","digimail-smtp")))))}const X=[{key:"overview",label:(0,i.__)("Overview","digimail-smtp"),icon:"chart"},{key:"logs",label:(0,i.__)("Email log","digimail-smtp"),icon:"list"},{key:"contacts",label:(0,i.__)("Customers","digimail-smtp"),icon:"users"},{key:"test",label:(0,i.__)("Test email","digimail-smtp"),icon:"send"},{key:"settings",label:(0,i.__)("Settings","digimail-smtp"),icon:"settings"},{key:"tools",label:(0,i.__)("Tools","digimail-smtp"),icon:"tools"}],ee=()=>{const e=window.location.hash.replace("#","");return X.some(t=>t.key===e)?e:"overview"},te=document.getElementById("digimail-smtp-app");if(te){const e=(0,l.createElement)(function({children:e}){const[t,a]=(0,l.useState)([]),i=(0,l.useCallback)((e,t="ok")=>{const l=Date.now()+Math.random();a(a=>[...a,{id:l,msg:e,tone:t}]),setTimeout(()=>a(e=>e.filter(e=>e.id!==l)),4500)},[]);return(0,l.createElement)(S.Provider,{value:i},e,(0,l.createElement)("div",{className:"dms-toasts",role:"status","aria-live":"polite"},t.map(e=>(0,l.createElement)("div",{key:e.id,className:`dms-toast dms-toast-${e.tone}`},(0,l.createElement)(w,{name:"ok"===e.tone?"check":"alert",size:16}),e.msg))))},null,(0,l.createElement)(function(){const e=C(),[t,a]=(0,l.useState)(null),[n,s]=(0,l.useState)(""),[m,r]=(0,l.useState)(ee),[c,o]=(0,l.useState)(!1),p=(0,l.useCallback)(async(e=!1)=>{try{a(await d("state"+(e?"?refresh=1":""))),s("")}catch(e){s(e.message)}},[]);(0,l.useEffect)(()=>{p();const t=window.digimailSmtp?.flash;t&&e(t.message,t.ok?"ok":"bad")},[p,e]),(0,l.useEffect)(()=>{const e=()=>r(ee());return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)},[]);const u=e=>{window.location.hash=e,r(e),window.scrollTo({top:0})};if(n&&!t)return(0,l.createElement)("div",{className:"dms"},(0,l.createElement)(v,{tone:"bad",title:(0,i.__)("DigiMail SMTP could not load","digimail-smtp")},n));if(!t)return(0,l.createElement)("div",{className:"dms"},(0,l.createElement)("div",{className:"dms-skel",style:{height:420}}));if(!t.connected)return(0,l.createElement)("div",{className:"dms"},(0,l.createElement)(T,{state:t,reload:async()=>{await p(!0),o(!0),u("overview")}}));const g=t.status.sender;return(0,l.createElement)("div",{className:"dms"},(0,l.createElement)("header",{className:"dms-top"},(0,l.createElement)("div",{className:"dms-brand"},(0,l.createElement)("img",{src:window.digimailSmtp?.logo,alt:"",width:30,height:30}),(0,l.createElement)("div",null,(0,l.createElement)("strong",null,"DigiMail SMTP"),(0,l.createElement)("span",null,t.revoked?(0,l.createElement)(h,{tone:"bad"},(0,i.__)("Disconnected","digimail-smtp")):(0,l.createElement)(h,{tone:"ok"},(0,i._x)("Active","connection status","digimail-smtp"))))),(0,l.createElement)("nav",{className:"dms-tabs","aria-label":"DigiMail SMTP"},X.map(e=>(0,l.createElement)("a",{key:e.key,href:`#${e.key}`,className:m===e.key?"is-on":"","aria-current":m===e.key?"page":void 0,onClick:t=>{t.preventDefault(),u(e.key)}},(0,l.createElement)(w,{name:e.icon,size:16}),e.label,"logs"===e.key&&t.queue.failed>0&&(0,l.createElement)("span",{className:"dms-count"},t.queue.failed))))),t.revoked&&(0,l.createElement)(v,{tone:"bad",title:(0,i.__)("This website was disconnected on digimail.vn","digimail-smtp"),action:(0,l.createElement)(f,{onClick:async()=>{await d("disconnect",{}),p(!0)}},(0,i.__)("Reconnect","digimail-smtp"))},t.settings.backup.enabled?(0,i.__)("Email is not going through DigiMail. The backup server is sending it.","digimail-smtp"):(0,i.__)("Email is not going through DigiMail.","digimail-smtp")),c&&g&&(0,l.createElement)("div",{className:"dms-welcome"},(0,l.createElement)("div",{className:"dms-welcome-icon"},(0,l.createElement)(w,{name:"check",size:28})),(0,l.createElement)("div",null,(0,l.createElement)("h2",null,(0,i.__)("Done! This website can send email now.","digimail-smtp")),(0,l.createElement)("p",null,(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: %s: sender email address. */ /* translators: %s: sender email address. */(0,i.__)("Email will be sent from <strong>%s</strong>. Send a test email to make sure everything works.","digimail-smtp"),g.email),{strong:(0,l.createElement)("strong",null)}))),(0,l.createElement)(f,{onClick:()=>{o(!1),u("test")}},(0,l.createElement)(w,{name:"send",size:16})," ",(0,i.__)("Send a test email","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"dms-icon-btn","aria-label":(0,i.__)("Close","digimail-smtp"),onClick:()=>o(!1)},(0,l.createElement)(w,{name:"x"}))),(0,l.createElement)("main",null,"overview"===m&&(0,l.createElement)($,{state:t,go:u}),"logs"===m&&(0,l.createElement)(j,{reload:()=>p()}),"contacts"===m&&(0,l.createElement)(B,{state:t,go:u}),"test"===m&&(0,l.createElement)(V,{state:t,go:u}),"settings"===m&&(0,l.createElement)(Q,{state:t,setState:a}),"tools"===m&&(0,l.createElement)(Z,{state:t,setState:a})),(0,l.createElement)("footer",{className:"dms-foot"},"DigiMail SMTP ",t.env.plugin," · ",(0,l.createElement)("a",{href:t.env.app,target:"_blank",rel:"noreferrer"},"digimail.vn")))},null));"function"==typeof l.createRoot?(0,l.createRoot)(te).render(e):(0,l.render)(e,te)}}};const t={};function a(l){const i=t[l];if(void 0!==i)return i.exports;const n=t[l]={exports:{}};return e[l](n,n.exports,a),n.exports}a.m=e,(()=>{const e=[];a.O=(t,l,i)=>{if(!l){for(var n=0;n<e.length;n++){let[l,i]=e[n],m=!0;for(var s=0;s<l.length;s++)a.O.j(l[s])?l.splice(s--,1):m=!1;if(m){e.splice(n--,1);const a=i();void 0!==a&&(t=a)}}return t}e.push([l,i])}})(),a.n=e=>{const t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var l in t)a.o(t,l)&&!a.o(e,l)&&Object.defineProperty(e,l,{enumerable:!0,get:t[l]})},a.o=(e,t)=>Object.hasOwn(e,t),(()=>{const e={57:0,350:0};a.O.j=t=>0===e[t];const t=(t,l)=>{let[i,n,s]=l;var m,r,d=0;if(i.some(t=>0!==e[t])){for(m in n)a.o(n,m)&&(a.m[m]=n[m]);if(s)var c=s(a)}for(t&&t(l);d<i.length;d++)r=i[d],a.o(e,r)&&e[r]&&e[r][0](),e[r]=0;return a.O(c)},l=Array.isArray(globalThis.webpackChunkdigimail_smtp)?globalThis.webpackChunkdigimail_smtp:globalThis.webpackChunkdigimail_smtp=[];l.forEach(t.bind(null,0)),l.push=t.bind(null,l.push.bind(l))})();let l=a.O(void 0,[350],()=>a(402));l=a.O(l)})(); -
digimail-smtp/tags/2.5.1/digimail-smtp.php
r3829755 r3829867 4 4 * Plugin URI: https://digimail.vn 5 5 * Description: Send WordPress email without setting up SMTP: activate, enter your email, and your site sends mail right away. Email log with real delivery status, background sending, backup connection, email controls, and many sites managed on digimail.vn. 6 * Version: 2.5. 06 * Version: 2.5.1 7 7 * Requires at least: 6.2 8 8 * Requires PHP: 7.4 … … 20 20 } 21 21 22 define( 'DIGIMAIL_SMTP_VERSION', '2.5. 0' );22 define( 'DIGIMAIL_SMTP_VERSION', '2.5.1' ); 23 23 define( 'DIGIMAIL_SMTP_FILE', __FILE__ ); 24 24 define( 'DIGIMAIL_SMTP_DIR', plugin_dir_path( __FILE__ ) ); -
digimail-smtp/tags/2.5.1/includes/Plugin.php
r3829755 r3829867 33 33 Admin::init(); 34 34 Widget::init(); 35 Review::init(); 35 36 } 36 37 if ( file_exists( __DIR__ . '/Updater.php' ) ) { -
digimail-smtp/tags/2.5.1/includes/Queue.php
r3829755 r3829867 111 111 $r['ok'] = true; 112 112 } 113 if ( $r['ok'] ) { 114 Review::count(); 115 } 113 116 return array( 114 117 'ok' => $r['ok'], -
digimail-smtp/tags/2.5.1/includes/Rest.php
r3829755 r3829867 698 698 'email' => (bool) $req->get_param( 'email' ), 699 699 'telegram' => (bool) $req->get_param( 'telegram' ), 700 ) 700 ) + ( null !== $req->get_param( 'weekly' ) ? array( 'weekly' => (bool) $req->get_param( 'weekly' ) ) : array() ) 701 701 ) 702 702 ); -
digimail-smtp/tags/2.5.1/readme.txt
r3829755 r3829867 5 5 Tested up to: 7.1 6 6 Requires PHP: 7.4 7 Stable tag: 2.5. 07 Stable tag: 2.5.1 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 36 36 * Verify your own domain from the plugin: the DNS records to add with copy buttons and live status, one-click setup through Cloudflare, a zone file to import, and the plugin switches to your domain by itself once verified. 37 37 * Alerts by Telegram and email: failing emails, quota nearly used up, rising bounces or spam reports, a plugin that stopped reporting, forms hit by bots, domain verified or failing. 38 * Weekly summary by email every Monday: emails sent, delivery rate and spam blocked on each website, and the month's quota. Nothing is sent after a quiet week, and it can be turned off. 38 39 * Email to addresses typed by visitors is checked by DigiMail before it goes out (real address, domain that takes mail, not bounced before, not mailed too often), so bots cannot use your forms to send email to strangers. 39 40 * Email controls: turn off WordPress default notifications you do not need (new comments, new users, password changes, automatic updates). … … 116 117 == Changelog == 117 118 119 = 2.5.1 = 120 * Weekly summary email (on by default, can be turned off in Settings → Alerts). 121 * After 50 emails delivered, a one-time request to review the plugin on WordPress.org, on the Dashboard and the plugin screen only. 122 118 123 = 2.5.0 = 119 124 * Resend any email from the log, to its recipient or to another address. -
digimail-smtp/tags/2.5.1/src/Alerts.tsx
r3829755 r3829867 11 11 type AlertsInfo = { 12 12 telegram: { available: boolean; bot: string | null; chats: Chat[] }; 13 prefs: { email: boolean; telegram: boolean };13 prefs: { email: boolean; telegram: boolean; weekly?: boolean }; 14 14 emails: string[]; 15 15 recent: Recent[]; … … 163 163 hint={ sprintf( /* translators: %s: email addresses. */ __( 'To %s (the users of your DigiMail account).', 'digimail-smtp' ), info.emails.join( ', ' ) ) } /> 164 164 165 { info.prefs.weekly !== undefined && ( 166 <Toggle checked={ info.prefs.weekly } disabled={ busy === 'prefs' } onChange={ ( v ) => prefs( { ...info.prefs, weekly: v } ) } 167 label={ __( 'Weekly summary by email', 'digimail-smtp' ) } 168 hint={ __( 'Every Monday morning: emails sent last week, delivery rate, spam blocked on each website and the month’s quota. Nothing is sent after a quiet week.', 'digimail-smtp' ) } /> 169 ) } 170 165 171 <div><Button variant="secondary" size="sm" busy={ busy === 'test' } disabled={ ! on } onClick={ test }><Icon name="bell" size={ 14 } /> { __( 'Send a test alert', 'digimail-smtp' ) }</Button></div> 166 172 -
digimail-smtp/tags/2.5.1/uninstall.php
r3829755 r3829867 17 17 global $wpdb; 18 18 $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}digimail_smtp_queue" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 19 foreach ( array( 'digimail_smtp_settings', 'digimail_smtp_token', 'digimail_smtp_status', 'digimail_smtp_db', 'digimail_smtp_revoked', 'digimail_smtp_last_failure', 'digimail_smtp_imported', 'digimail_smtp_contacts', 'digimail_smtp_contacts_last', 'digimail_smtp_guard_log', 'digimail_smtp_guard_stats', 'digimail_smtp_guard_seen', 'digimail_smtp_guard_secret', 'digimail_smtp_guard_allow' ) as $digimail_smtp_option ) {19 foreach ( array( 'digimail_smtp_settings', 'digimail_smtp_token', 'digimail_smtp_status', 'digimail_smtp_db', 'digimail_smtp_revoked', 'digimail_smtp_last_failure', 'digimail_smtp_imported', 'digimail_smtp_contacts', 'digimail_smtp_contacts_last', 'digimail_smtp_guard_log', 'digimail_smtp_guard_stats', 'digimail_smtp_guard_seen', 'digimail_smtp_guard_secret', 'digimail_smtp_guard_allow', 'digimail_smtp_limit_hit', 'digimail_smtp_review' ) as $digimail_smtp_option ) { 20 20 delete_option( $digimail_smtp_option ); 21 21 } -
digimail-smtp/trunk/build/index.asset.php
r3829755 r3829867 5 5 'wp-i18n' 6 6 ), 7 'version' => ' b0b2b2c165474d304b79'7 'version' => 'dd914ccc1737aec07d63' 8 8 ); -
digimail-smtp/trunk/build/index.js
r3829755 r3829867 10 10 (0,i.__)("Last 30 days: %1$s of %2$s submissions blocked. See them in the Customers tab.","digimail-smtp"),o(s.blocked),o(s.checked)))))}function W({summary:e}){const t=C(),[a,n]=(0,l.useState)(null),[s,r]=(0,l.useState)(""),[c,u]=(0,l.useState)(""),[_,h]=(0,l.useState)(""),b=(0,l.useCallback)(()=>d("guard/log").then(e=>n(e.items)).catch(e=>r(e.message)),[]);(0,l.useEffect)(()=>{b()},[b]);const y=Object.entries(e.reasons).slice(0,4);return(0,l.createElement)(E,{title:(0,i.__)("Spam blocked","digimail-smtp"),aside:(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:b,"aria-label":(0,i.__)("Reload","digimail-smtp")},(0,l.createElement)(w,{name:"refresh",size:15}))},(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.sprintf)(/* translators: 1: blocked submissions, 2: checked submissions. */ /* translators: 1: blocked submissions, 2: checked submissions. */ 11 11 (0,i.__)("Last 30 days: %1$s of %2$s submissions blocked. No email was sent for them and they were not saved as contacts.","digimail-smtp"),o(e.blocked),o(e.checked)),y.length>0&&(0,l.createElement)(l.Fragment,null," ",(0,i.__)("Most common reasons:","digimail-smtp")," ",y.map(([e,t])=>`${m[e]??e} (${o(t)})`).join("; "),".")),s&&(0,l.createElement)("p",{className:"dms-error"},s),!a&&!s&&(0,l.createElement)("div",{className:"dms-skel",style:{height:240}}),a&&0===a.length&&(0,l.createElement)(k,{icon:(0,l.createElement)(w,{name:"shield",size:26}),title:(0,i.__)("Nothing blocked yet","digimail-smtp")},(0,i.__)("Bot submissions show up here. If a real customer says the form did not work, find them here and click “Not spam”.","digimail-smtp")),a&&a.length>0&&(0,l.createElement)("table",{className:"dms-table"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Sender","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Form","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Why","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Time","digimail-smtp")),(0,l.createElement)("th",null))),(0,l.createElement)("tbody",null,a.map(e=>(0,l.createElement)(l.Fragment,{key:e.id},(0,l.createElement)("tr",null,(0,l.createElement)("td",{className:"dms-ellipsis"},(0,l.createElement)("strong",null,e.name||e.email||"—"),e.name&&e.email&&(0,l.createElement)("div",{className:"dms-muted dms-small"},e.email),e.phone&&(0,l.createElement)("div",{className:"dms-muted dms-small"},e.phone)),(0,l.createElement)("td",{className:"dms-small"},[g(e.source),e.form].filter(Boolean).join(" · "),(0,l.createElement)("div",{className:"dms-muted"},e.ip)),(0,l.createElement)("td",{className:"dms-small"},(0,l.createElement)("ul",{className:"dms-reasons"},e.reasons.map(e=>(0,l.createElement)("li",{key:e},m[e]??e))),e.text&&(0,l.createElement)("button",{type:"button",className:"dms-link",onClick:()=>h(_===e.id?"":e.id)},_===e.id?(0,i.__)("Hide message","digimail-smtp"):(0,i.__)("Show message","digimail-smtp"))),(0,l.createElement)("td",{className:"dms-small dms-muted",title:new Date(1e3*e.at).toLocaleString()},p(new Date(1e3*e.at).toISOString())),(0,l.createElement)("td",{className:"dms-actions"},(0,l.createElement)(f,{size:"sm",variant:"secondary",busy:c===e.id,onClick:()=>(async e=>{u(e);try{await d("guard/restore",{id:e}),n(t=>(t??[]).filter(t=>t.id!==e)),t((0,i.__)("Marked as not spam. This address will not be blocked again.","digimail-smtp"))}catch(e){t(e.message,"bad")}finally{u("")}})(e.id)},(0,i.__)("Not spam","digimail-smtp")))),_===e.id&&(0,l.createElement)("tr",{className:"dms-subrow"},(0,l.createElement)("td",{colSpan:5},(0,l.createElement)("pre",{className:"dms-message"},e.text))))))),a&&a.length>0&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.sprintf)(/* translators: %s: number of entries kept. */ /* translators: %s: number of entries kept. */ 12 (0,i._n)("The latest %s blocked submission is kept on this website.","The latest %s blocked submissions are kept on this website.",a.length,"digimail-smtp"),o(a.length))))}const R={added:{label:(0,i.__)("New","digimail-smtp"),tone:"ok",hint:(0,i.__)("Added to the contact list.","digimail-smtp")},existing:{label:(0,i.__)("Already in list","digimail-smtp"),tone:"info",hint:(0,i.__)("This address was already in the list.","digimail-smtp")},blocked:{label:(0,i.__)("Blocked","digimail-smtp"),tone:"wait",hint:(0,i.__)("Unsubscribed, bounced or reported spam before, so it is not added back.","digimail-smtp")},invalid:{label:(0,i.__)("Invalid email","digimail-smtp"),tone:"bad",hint:(0,i.__)("The address cannot receive email.","digimail-smtp")}},q=e=>[g(e.source??"")||e.source,e.form].filter(Boolean).join(" · ")||(0,i.__)("Other","digimail-smtp");function B({state:e,go:t}){const a=C(),[n,s]=(0,l.useState)(""),[m,r]=(0,l.useState)(""),[u,_]=(0,l.useState)(1),[b,y]=(0,l.useState)(null),[N,S]=(0,l.useState)(""),[M,T]=(0,l.useState)(!1),[D,x]=(0,l.useState)(!1),z=(0,l.useCallback)(e=>{const t=new URLSearchParams;return e&&t.set("page",String(u)),n&&t.set("form",n),m.trim()&&t.set("q",m.trim()),t.toString()},[u,n,m]),$=(0,l.useCallback)(()=>d(`entries?${z(!0)}`).then(e=>{y(e),S("")}).catch(e=>S(e.message)),[z]);(0,l.useEffect)(()=>{const e=setTimeout($,m?300:0);return()=>clearTimeout(e)},[$,m]);const P=b?Math.max(1,Math.ceil(b.total/b.per_page)):1,F=b?b.forms.reduce((e,t)=>e+t.count,0):0,I=e.settings.capture.enabled,O=e.guard;return(0,l.createElement)("div",{className:"dms-stack"},!I&&(0,l.createElement)(v,{tone:"info",title:(0,i.__)("Saving form contacts is off","digimail-smtp"),action:(0,l.createElement)(f,{variant:"secondary",size:"sm",onClick:()=>t("settings")},(0,i.__)("Turn on","digimail-smtp"))},(0,i.__)("Turn it on in Settings and the people who fill in your forms show up here.","digimail-smtp")),b&&(b.forms.length>0||O.enabled)&&(0,l.createElement)("div",{className:"dms-formcards"},(0,l.createElement)("button",{type:"button",className:D||""!==n?"":"is-on",onClick:()=>{x(!1),s(""),_(1)}},(0,l.createElement)("span",null,(0,i.__)("All forms","digimail-smtp")),(0,l.createElement)("strong",null,o(F))),b.forms.map(e=>(0,l.createElement)("button",{key:e.key,type:"button",className:D||n!==e.key?"":"is-on",onClick:()=>{x(!1),s(e.key),_(1)}},(0,l.createElement)("span",{className:"dms-ellipsis",title:q(e)},e.form||g(e.source??"")||e.source||(0,i.__)("Other","digimail-smtp")),(0,l.createElement)("strong",null,o(e.count)),(0,l.createElement)("small",{className:"dms-ellipsis"},e.form&&e.source?(g(e.source)||e.source)+" · ":"",(0,i.sprintf)(/* translators: %s: time of the last entry. */ /* translators: %s: time of the last entry. */12 (0,i._n)("The latest %s blocked submission is kept on this website.","The latest %s blocked submissions are kept on this website.",a.length,"digimail-smtp"),o(a.length))))}const q={added:{label:(0,i.__)("New","digimail-smtp"),tone:"ok",hint:(0,i.__)("Added to the contact list.","digimail-smtp")},existing:{label:(0,i.__)("Already in list","digimail-smtp"),tone:"info",hint:(0,i.__)("This address was already in the list.","digimail-smtp")},blocked:{label:(0,i.__)("Blocked","digimail-smtp"),tone:"wait",hint:(0,i.__)("Unsubscribed, bounced or reported spam before, so it is not added back.","digimail-smtp")},invalid:{label:(0,i.__)("Invalid email","digimail-smtp"),tone:"bad",hint:(0,i.__)("The address cannot receive email.","digimail-smtp")}},R=e=>[g(e.source??"")||e.source,e.form].filter(Boolean).join(" · ")||(0,i.__)("Other","digimail-smtp");function B({state:e,go:t}){const a=C(),[n,s]=(0,l.useState)(""),[m,r]=(0,l.useState)(""),[u,_]=(0,l.useState)(1),[b,y]=(0,l.useState)(null),[N,S]=(0,l.useState)(""),[M,T]=(0,l.useState)(!1),[D,x]=(0,l.useState)(!1),z=(0,l.useCallback)(e=>{const t=new URLSearchParams;return e&&t.set("page",String(u)),n&&t.set("form",n),m.trim()&&t.set("q",m.trim()),t.toString()},[u,n,m]),$=(0,l.useCallback)(()=>d(`entries?${z(!0)}`).then(e=>{y(e),S("")}).catch(e=>S(e.message)),[z]);(0,l.useEffect)(()=>{const e=setTimeout($,m?300:0);return()=>clearTimeout(e)},[$,m]);const P=b?Math.max(1,Math.ceil(b.total/b.per_page)):1,F=b?b.forms.reduce((e,t)=>e+t.count,0):0,I=e.settings.capture.enabled,O=e.guard;return(0,l.createElement)("div",{className:"dms-stack"},!I&&(0,l.createElement)(v,{tone:"info",title:(0,i.__)("Saving form contacts is off","digimail-smtp"),action:(0,l.createElement)(f,{variant:"secondary",size:"sm",onClick:()=>t("settings")},(0,i.__)("Turn on","digimail-smtp"))},(0,i.__)("Turn it on in Settings and the people who fill in your forms show up here.","digimail-smtp")),b&&(b.forms.length>0||O.enabled)&&(0,l.createElement)("div",{className:"dms-formcards"},(0,l.createElement)("button",{type:"button",className:D||""!==n?"":"is-on",onClick:()=>{x(!1),s(""),_(1)}},(0,l.createElement)("span",null,(0,i.__)("All forms","digimail-smtp")),(0,l.createElement)("strong",null,o(F))),b.forms.map(e=>(0,l.createElement)("button",{key:e.key,type:"button",className:D||n!==e.key?"":"is-on",onClick:()=>{x(!1),s(e.key),_(1)}},(0,l.createElement)("span",{className:"dms-ellipsis",title:R(e)},e.form||g(e.source??"")||e.source||(0,i.__)("Other","digimail-smtp")),(0,l.createElement)("strong",null,o(e.count)),(0,l.createElement)("small",{className:"dms-ellipsis"},e.form&&e.source?(g(e.source)||e.source)+" · ":"",(0,i.sprintf)(/* translators: %s: time of the last entry. */ /* translators: %s: time of the last entry. */ 13 13 (0,i.__)("last %s","digimail-smtp"),p(e.last_at))))),O.enabled&&(0,l.createElement)("button",{type:"button",className:"is-spam "+(D?"is-on":""),onClick:()=>x(!0)},(0,l.createElement)("span",null,(0,l.createElement)(w,{name:"shield",size:14})," ",(0,i.__)("Spam blocked","digimail-smtp")),(0,l.createElement)("strong",null,o(O.blocked)),(0,l.createElement)("small",null,(0,i.__)("last 30 days","digimail-smtp")))),D&&(0,l.createElement)(W,{summary:O}),!D&&(0,l.createElement)(E,null,(0,l.createElement)("div",{className:"dms-toolbar"},(0,l.createElement)("div",{className:"dms-search"},(0,l.createElement)(w,{name:"search",size:16}),(0,l.createElement)("input",{value:m,onChange:e=>{r(e.target.value),_(1)},placeholder:(0,i.__)("Search name, email or phone","digimail-smtp"),"aria-label":(0,i.__)("Search","digimail-smtp")})),(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:()=>$(),"aria-label":(0,i.__)("Reload","digimail-smtp")},(0,l.createElement)(w,{name:"refresh",size:15})),(0,l.createElement)(f,{variant:"secondary",size:"sm",busy:M,disabled:!b||0===b.total,onClick:async()=>{T(!0);try{const e=await d(`entries/export?${z(!1)}`),t=URL.createObjectURL(new Blob([e.csv],{type:"text/csv;charset=utf-8"})),a=document.createElement("a");a.href=t,a.download="khach-dien-form.csv",a.click(),URL.revokeObjectURL(t)}catch(e){a(e.message,"bad")}finally{T(!1)}}},(0,l.createElement)(w,{name:"download",size:15})," ",(0,i.__)("Export CSV","digimail-smtp"))),e.capture.pending>0&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.sprintf)(/* translators: %s: number of contacts. */ /* translators: %s: number of contacts. */ 14 (0,i._n)("%s new entry is on its way to DigiMail.","%s new entries are on their way to DigiMail.",e.capture.pending,"digimail-smtp"),o(e.capture.pending))),N&&(0,l.createElement)("p",{className:"dms-error"},N),!b&&!N&&(0,l.createElement)("div",{className:"dms-skel",style:{height:320}}),b&&0===b.entries.length&&(0,l.createElement)(k,{icon:(0,l.createElement)(w,{name:"users",size:26}),title:m||n?(0,i.__)("No matching entries","digimail-smtp"):(0,i.__)("No form entries yet","digimail-smtp")},m||n?(0,i.__)("Try another filter.","digimail-smtp"):(0,i.__)("When someone fills in a form or places an order, they show up here with the form and page they used.","digimail-smtp")),b&&b.entries.length>0&&(0,l.createElement)("table",{className:"dms-table"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Customer","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Phone","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Form","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Page","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Result","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Time","digimail-smtp")))),(0,l.createElement)("tbody",null,b.entries.map(e=>{const t= R[e.outcome];return(0,l.createElement)("tr",{key:e.id},(0,l.createElement)("td",{className:"dms-ellipsis"},(0,l.createElement)("strong",null,e.name||e.email),e.name&&(0,l.createElement)("div",{className:"dms-small dms-muted dms-ellipsis"},e.email),e.company&&(0,l.createElement)("div",{className:"dms-small dms-muted dms-ellipsis"},e.company)),(0,l.createElement)("td",{className:"dms-small"},e.phone?(0,l.createElement)("a",{href:`tel:${e.phone.replace(/[^\d+]/g,"")}`},e.phone):(0,l.createElement)("span",{className:"dms-muted"},"—")),(0,l.createElement)("td",{className:"dms-small dms-ellipsis"},q(e)),(0,l.createElement)("td",{className:"dms-small dms-ellipsis"},e.page?(0,l.createElement)("a",{href:e.page,target:"_blank",rel:"noreferrer"},(e=>{try{const t=new URL(e);return decodeURIComponent(t.pathname)||"/"}catch{return e}})(e.page)):(0,l.createElement)("span",{className:"dms-muted"},"—")),(0,l.createElement)("td",{title:t.hint},(0,l.createElement)(h,{tone:t.tone},t.label)),(0,l.createElement)("td",{className:"dms-small dms-muted",title:new Date(e.submitted_at).toLocaleString(c)},p(e.submitted_at)))}))),b&&P>1&&(0,l.createElement)("div",{className:"dms-pager"},(0,l.createElement)("span",{className:"dms-muted dms-small"},(0,i.sprintf)(/* translators: %s: number of entries. */ /* translators: %s: number of entries. */14 (0,i._n)("%s new entry is on its way to DigiMail.","%s new entries are on their way to DigiMail.",e.capture.pending,"digimail-smtp"),o(e.capture.pending))),N&&(0,l.createElement)("p",{className:"dms-error"},N),!b&&!N&&(0,l.createElement)("div",{className:"dms-skel",style:{height:320}}),b&&0===b.entries.length&&(0,l.createElement)(k,{icon:(0,l.createElement)(w,{name:"users",size:26}),title:m||n?(0,i.__)("No matching entries","digimail-smtp"):(0,i.__)("No form entries yet","digimail-smtp")},m||n?(0,i.__)("Try another filter.","digimail-smtp"):(0,i.__)("When someone fills in a form or places an order, they show up here with the form and page they used.","digimail-smtp")),b&&b.entries.length>0&&(0,l.createElement)("table",{className:"dms-table"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Customer","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Phone","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Form","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Page","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Result","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Time","digimail-smtp")))),(0,l.createElement)("tbody",null,b.entries.map(e=>{const t=q[e.outcome];return(0,l.createElement)("tr",{key:e.id},(0,l.createElement)("td",{className:"dms-ellipsis"},(0,l.createElement)("strong",null,e.name||e.email),e.name&&(0,l.createElement)("div",{className:"dms-small dms-muted dms-ellipsis"},e.email),e.company&&(0,l.createElement)("div",{className:"dms-small dms-muted dms-ellipsis"},e.company)),(0,l.createElement)("td",{className:"dms-small"},e.phone?(0,l.createElement)("a",{href:`tel:${e.phone.replace(/[^\d+]/g,"")}`},e.phone):(0,l.createElement)("span",{className:"dms-muted"},"—")),(0,l.createElement)("td",{className:"dms-small dms-ellipsis"},R(e)),(0,l.createElement)("td",{className:"dms-small dms-ellipsis"},e.page?(0,l.createElement)("a",{href:e.page,target:"_blank",rel:"noreferrer"},(e=>{try{const t=new URL(e);return decodeURIComponent(t.pathname)||"/"}catch{return e}})(e.page)):(0,l.createElement)("span",{className:"dms-muted"},"—")),(0,l.createElement)("td",{title:t.hint},(0,l.createElement)(h,{tone:t.tone},t.label)),(0,l.createElement)("td",{className:"dms-small dms-muted",title:new Date(e.submitted_at).toLocaleString(c)},p(e.submitted_at)))}))),b&&P>1&&(0,l.createElement)("div",{className:"dms-pager"},(0,l.createElement)("span",{className:"dms-muted dms-small"},(0,i.sprintf)(/* translators: %s: number of entries. */ /* translators: %s: number of entries. */ 15 15 (0,i._n)("%s entry","%s entries",b.total,"digimail-smtp"),o(b.total))),(0,l.createElement)(f,{variant:"secondary",size:"sm",disabled:u<=1,onClick:()=>_(u-1)},(0,i.__)("Previous","digimail-smtp")),(0,l.createElement)("span",{className:"dms-small"},(0,i.sprintf)(/* translators: 1: current page, 2: number of pages. */ /* translators: 1: current page, 2: number of pages. */ 16 16 (0,i.__)("Page %1$d of %2$d","digimail-smtp"),u,P)),(0,l.createElement)(f,{variant:"secondary",size:"sm",disabled:u>=P,onClick:()=>_(u+1)},(0,i.__)("Next","digimail-smtp")))))}function V({state:e,go:t}){const[a,n]=(0,l.useState)(e.site.user_email),[s,m]=(0,l.useState)("html"),[r,c]=(0,l.useState)(!1),[o,p]=(0,l.useState)(null),[u,g]=(0,l.useState)("");return(0,l.createElement)("div",{className:"dms-grid-main"},(0,l.createElement)(E,{title:(0,i.__)("Send a test email","digimail-smtp")},e.interceptors.length>0&&(0,l.createElement)(v,{tone:"bad",title:(0,i.sprintf)(/* translators: %s: plugin names. */ /* translators: %s: plugin names. */(0,i.__)("%s is taking over wp_mail()","digimail-smtp"),e.interceptors.join(", "))},(0,i.__)("Your website’s emails stop at that plugin and never reach DigiMail. Deactivate it on the Plugins page.","digimail-smtp")),(0,l.createElement)("form",{className:"dms-form",onSubmit:e=>{e.preventDefault(),(async()=>{c(!0),g(""),p(null);try{p(await d("test",{to:a,format:s}))}catch(e){g(e.message)}finally{c(!1)}})()}},(0,l.createElement)("p",{className:"dms-muted"},(0,i.__)("The test goes through the same wp_mail() function your website and plugins use, so if it works, order emails and contact forms work too.","digimail-smtp")),(0,l.createElement)(y,{label:(0,i.__)("Send to","digimail-smtp"),htmlFor:"dms-to"},(0,l.createElement)("input",{id:"dms-to",type:"email",required:!0,value:a,onChange:e=>n(e.target.value)})),(0,l.createElement)("div",{className:"dms-field"},(0,l.createElement)("span",{className:"dms-label"},(0,i.__)("Format","digimail-smtp")),(0,l.createElement)("div",{className:"dms-seg"},(0,l.createElement)("button",{type:"button",className:"html"===s?"is-on":"",onClick:()=>m("html")},"HTML"),(0,l.createElement)("button",{type:"button",className:"text"===s?"is-on":"",onClick:()=>m("text")},(0,i.__)("Plain text","digimail-smtp")))),(0,l.createElement)("div",null,(0,l.createElement)(f,{type:"submit",busy:r},(0,l.createElement)(w,{name:"send",size:16})," ",(0,i.__)("Send test email","digimail-smtp")))),o&&(0,l.createElement)(v,{tone:"ok",title:"backup"===o.via?(0,i.__)("Sent through the backup server","digimail-smtp"):(0,i.__)("Sent. Check your inbox.","digimail-smtp"),action:"digimail"===o.via&&(0,l.createElement)(f,{variant:"secondary",size:"sm",onClick:()=>t("logs")},(0,i.__)("See status","digimail-smtp"))},(0,i.sprintf)(/* translators: 1: sender name, 2: sender email, 3: seconds taken. */ /* translators: 1: sender name, 2: sender email, 3: seconds taken. */ … … 22 22 (0,i.__)("%1$s contacts added so far, last sync %2$s.","digimail-smtp"),o(_.total??0),p(new Date(1e3*_.at).toISOString())):(0,i.__)("No contacts yet. They show up a few seconds after someone submits a form.","digimail-smtp"),k>0&&(0,l.createElement)(l.Fragment,null," ",(0,i.sprintf)(/* translators: %s: number of contacts. */ /* translators: %s: number of contacts. */(0,i.__)("%s waiting to be sent.","digimail-smtp"),o(k)))),k>0&&(0,l.createElement)(f,{size:"sm",variant:"secondary",busy:"sync"===u,onClick:async()=>{g("sync");try{const e=await d("contacts/sync",{});w(e.pending),v(e.last),e.last?.error?n(e.last.error,"bad"):n((0,i.__)("Contacts sent to DigiMail.","digimail-smtp"))}catch(e){n(e.message,"bad")}finally{g(null)}}},(0,i.__)("Send now","digimail-smtp"))),(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("Send marketing email only to people who agreed to receive it. Add an “I agree to receive news” checkbox to your forms.","digimail-smtp")))))}const G={ok:{label:(0,i.__)("Correct","digimail-smtp"),tone:"ok"},missing:{label:(0,i.__)("Not added yet","digimail-smtp"),tone:"wait"},wrong:{label:(0,i.__)("Wrong value","digimail-smtp"),tone:"bad"},unknown:{label:(0,i.__)("Could not check","digimail-smtp"),tone:"muted"}};function H({text:e,label:t}){const a=C();return(0,l.createElement)("button",{type:"button",className:"dms-copy",title:(0,i.__)("Copy","digimail-smtp"),"aria-label":(0,i.sprintf)(/* translators: %s: what is copied. */ /* translators: %s: what is copied. */(0,i.__)("Copy %s","digimail-smtp"),t),onClick:async()=>a(await async function(e){try{return await navigator.clipboard.writeText(e),!0}catch{const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();const a=document.execCommand("copy");return t.remove(),a}}(e)?(0,i.__)("Copied.","digimail-smtp"):(0,i.__)("Could not copy. Select the text and copy it by hand.","digimail-smtp"))},(0,l.createElement)("code",null,e),(0,l.createElement)(w,{name:"copy",size:14}))}function K({state:e,setState:t}){const a=C(),[n,s]=(0,l.useState)(null),[m,r]=(0,l.useState)(""),[c,p]=(0,l.useState)(""),[u,g]=(0,l.useState)(""),[_,b]=(0,l.useState)(""),k=(0,l.useCallback)(()=>d("domain").then(e=>(s(e),r(""),e)).catch(e=>(r(e.message),null)),[]);(0,l.useEffect)(()=>{k()},[k]);const N="pending"===n?.state;(0,l.useEffect)(()=>{if(!N)return;let e=0;const t=setInterval(()=>{e++,e>20||document.hidden?e>20&&clearInterval(t):k()},3e4);return()=>clearInterval(t)},[N,k]);const S="verified"===n?.state;(0,l.useEffect)(()=>{S&&"shared"===e.status.sender?.mode&&d("state?refresh=1").then(t).catch(()=>{})},[S,e.status.sender?.mode,t]);const M=async(e,t,l={})=>{p(e);try{const e=await d(t,l);return s(e),e}catch(e){return a(e.message,"bad"),null}finally{p("")}},T=async()=>{const e=await M("cf","domain/cloudflare",{token:u});e?.applied&&(g(""),a(e.applied.problems>0?(0,i.sprintf)(/* translators: %s: number of records. */ /* translators: %s: number of records. */(0,i.__)("Added what could be added. %s records need a look: see the list.","digimail-smtp"),o(e.applied.problems)):(0,i.__)("Records added in Cloudflare. Verification usually finishes within a few minutes.","digimail-smtp")))},D=n?"verified"===n.state?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("Verified","digimail-smtp")):"pending"===n.state?(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Waiting for DNS","digimail-smtp")):"failed"===n.state?(0,l.createElement)(h,{tone:"bad"},(0,i.__)("Not verified","digimail-smtp")):(0,l.createElement)(h,null,(0,i.__)("Shared address","digimail-smtp")):null,x=n?.dns?.zone??n?.zone??null,z="cloudflare"===x?.provider.key||(n?.dns?.cloudflare.can_apply??n?.can_apply??!1),$=n?.dns?.cloudflare.can_apply??n?.can_apply??!1,P=n?.dns?.cloudflare.token_url??n?.token_url??"",F=n&&x&&x.apex!==n.domain&&n.domain.endsWith(`.${x.apex}`)?[n.domain,x.apex]:null;return(0,l.createElement)(E,{title:(0,l.createElement)("span",{id:"dms-domain"},(0,i.__)("Sending domain","digimail-smtp")),aside:D},m&&(0,l.createElement)("p",{className:"dms-error"},m),!n&&!m&&(0,l.createElement)("div",{className:"dms-skel",style:{height:120}}),n&&!n.eligible&&(0,l.createElement)("p",{className:"dms-muted dms-small"},(0,i.__)("This website runs on an IP address or localhost, so it has no domain to verify. It keeps sending from the shared address.","digimail-smtp")),n?.eligible&&"taken"===n.state&&(0,l.createElement)(v,{tone:"wait",title:(0,i.sprintf)(/* translators: %s: domain. */ /* translators: %s: domain. */(0,i.__)("%s is already in another DigiMail account","digimail-smtp"),n.domain)},(0,i.__)("Log in to that account on digimail.vn, or contact DigiMail if you own this domain.","digimail-smtp")),n?.eligible&&"none"===n.state&&(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)("p",null,(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: 1: shared address, 2: example address on the site's domain. */ /* translators: 1: shared address, 2: example address on the site's domain. */ 23 23 (0,i.__)("The website sends from <code>%1$s</code>. Verify your domain to send from an address like <code>%2$s</code>: Gmail and Outlook trust it more, emails land in the inbox more often, and the shared address’s daily limit no longer applies.","digimail-smtp"),n.sender?.email??"",`noreply@${_||n.domain}`),{code:(0,l.createElement)("code",null)})),F&&(0,l.createElement)(y,{label:(0,i.__)("Domain to verify","digimail-smtp"),htmlFor:"dms-domain-pick",hint:(0,i.__)("Verifying the main domain covers every subdomain of it.","digimail-smtp")},(0,l.createElement)("select",{id:"dms-domain-pick",value:_||F[0],onChange:e=>b(e.target.value)},F.map(e=>(0,l.createElement)("option",{key:e,value:e},e)))),x&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: 1: domain, 2: DNS provider. */ /* translators: 1: domain, 2: DNS provider. */(0,i.__)("DNS of <strong>%1$s</strong> is managed at <strong>%2$s</strong>.","digimail-smtp"),x.apex,x.provider.name),{strong:(0,l.createElement)("strong",null)}),z&&(0,l.createElement)(l.Fragment,null," ",(0,i.__)("You can add the records with one click through Cloudflare.","digimail-smtp"))),(0,l.createElement)("div",null,(0,l.createElement)(f,{busy:"add"===c,onClick:()=>M("add","domain/add",_?{domain:_}:{})},(0,i.sprintf)(/* translators: %s: domain name. */ /* translators: %s: domain name. */(0,i.__)("Verify %s","digimail-smtp"),_||n.domain)))),n?.eligible&&"verified"===n.state&&(0,l.createElement)(v,{tone:"ok",title:(0,i.sprintf)(/* translators: %s: domain. */ /* translators: %s: domain. */(0,i.__)("%s is verified","digimail-smtp"),n.dns?.domain??n.domain)},"domain"===n.sender?.mode?(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: %s: sender address. */ /* translators: %s: sender address. */(0,i.__)("The website sends from <code>%s</code>.","digimail-smtp"),n.sender.email),{code:(0,l.createElement)("code",null)}):(0,i.__)("The website switches to your domain within a minute.","digimail-smtp")),n?.eligible&&("pending"===n.state||"failed"===n.state)&&n.dns&&(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)("p",{className:"dms-small"},(0,i.sprintf)(/* translators: 1: correct records, 2: required records. */ /* translators: 1: correct records, 2: required records. */ 24 (0,i.__)("%1$s of %2$s required DNS records are correct.","digimail-smtp"),o(n.dns.summary.ok_required),o(n.dns.summary.required))," ",n.dns.summary.dns_ready?(0,i.__)("DNS is ready: DigiMail confirms the domain within a few minutes, then the website switches to it by itself.","digimail-smtp"):(0,i.__)("Add the records below where your domain’s DNS is managed. Changes usually show within minutes, sometimes a few hours.","digimail-smtp")),z&&!n.dns.summary.dns_ready&&(0,l.createElement)("div",{className:"dms-cf"},(0,l.createElement)("strong",null,(0,i.__)("Add them automatically through Cloudflare","digimail-smtp")),$?(0,l.createElement)("div",null,(0,l.createElement)(f,{busy:"cf"===c,onClick:T},(0,i.__)("Add records in Cloudflare","digimail-smtp"))):(0,l.createElement)(l.Fragment,null,(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,l.createInterpolateElement)((0,i.__)("<a>Create a Cloudflare API token</a> (the link fills in the right permissions: Zone Read, DNS Edit), then paste it here. DigiMail stores it encrypted and only uses it to add these records.","digimail-smtp"),{a:(0,l.createElement)("a",{href:P,target:"_blank",rel:"noreferrer"})})),(0,l.createElement)("div",{className:"dms-row"},(0,l.createElement)("input",{type:"password",autoComplete:"off",value:u,onChange:e=>g(e.target.value),placeholder:(0,i.__)("Cloudflare API token","digimail-smtp"),"aria-label":(0,i.__)("Cloudflare API token","digimail-smtp")}),(0,l.createElement)(f,{busy:"cf"===c,disabled:u.trim().length<20,onClick:T},(0,i.__)("Connect and add records","digimail-smtp"))))),x&&!z&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: 1: DNS provider, 2: how to add records there. */ /* translators: 1: DNS provider, 2: how to add records there. */(0,i.__)("DNS is at <strong>%1$s</strong>. %2$s","digimail-smtp"),x.provider.name,x.provider.guide),{strong:(0,l.createElement)("strong",null)}),x.provider.url&&(0,l.createElement)(l.Fragment,null," ",(0,l.createElement)("a",{href:x.provider.url,target:"_blank",rel:"noreferrer"},(0,i.__)("Open","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:12})))),n.applied&&n.applied.problems>0&&(0,l.createElement)(v,{tone:"wait",title:(0,i.__)("Some records were left alone in Cloudflare","digimail-smtp")},(0,l.createElement)("ul",{className:"dms-reasons"},n.applied.outcomes.filter(e=>"conflict"===e.action||"failed"===e.action).map(e=>(0,l.createElement)("li",{key:e.name+e.type},e.type," ",e.name,": ",e.message)))),(0,l.createElement)("div",{className:"dms-table-wrap"},(0,l.createElement)("table",{className:"dms-table dms-dns"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Type","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Name (host)","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Value","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Status","digimail-smtp")))),(0,l.createElement)("tbody",null,n.dns.records.map(e=>(0,l.createElement)("tr",{key:e.type+e.name+e.value},(0,l.createElement)("td",null,(0,l.createElement)("strong",null,e.type),!e.required&&(0,l.createElement)("div",{className:"dms-small dms-muted"},(0,i.__)("recommended","digimail-smtp"))),(0,l.createElement)("td",null,(0,l.createElement)(H,{text:e.host||"@",label:(0,i.__)("name","digimail-smtp")})),(0,l.createElement)("td",null,(0,l.createElement)(H,{text:e.value,label:(0,i.__)("value","digimail-smtp")}),null!==e.priority&&(0,l.createElement)("div",{className:"dms-small dms-muted"},(0,i.sprintf)(/* translators: %s: MX priority. */ /* translators: %s: MX priority. */(0,i.__)("Priority: %s","digimail-smtp"),e.priority)),"CNAME"===e.type&&z&&(0,l.createElement)("div",{className:"dms-small dms-muted"},(0,i.__)("Proxy off (DNS only)","digimail-smtp"))),(0,l.createElement)("td",null,(0,l.createElement)(h,{tone:G[e.state].tone},G[e.state].label),"ok"!==e.state&&e.note&&(0,l.createElement)("div",{className:"dms-small dms-muted"},e.note))))))),(0,l.createElement)("div",{className:"dms-actions"},(0,l.createElement)(f,{busy:"check"===c,onClick:()=>M("check","domain/check")},(0,l.createElement)(w,{name:"refresh",size:15})," ",(0,i.__)("Check again","digimail-smtp")),(0,l.createElement)(f,{variant:"secondary",busy:"zone"===c,onClick:async()=>{p("zone");try{const e=await d("domain/zonefile"),t=URL.createObjectURL(new Blob([e.text],{type:"text/plain;charset=utf-8"})),a=document.createElement("a");a.href=t,a.download=`digimail-${n?.dns?.domain??"dns"}.txt`,a.click(),URL.revokeObjectURL(t)}catch(e){a(e.message,"bad")}finally{p("")}}},(0,l.createElement)(w,{name:"download",size:15})," ",(0,i.__)("Download zone file","digimail-smtp"))),(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("When the domain is verified, DigiMail tells you by Telegram or email (see Alerts).","digimail-smtp"))))}const Y={bad:"bad",warn:"wait",good:"ok"};function J(){const e=C(),[t,a]=(0,l.useState)(null),[n,s]=(0,l.useState)(""),[m,r]=(0,l.useState)(""),[c,u]=(0,l.useState)(null),g=(0,l.useRef)(null),_=(0,l.useCallback)(()=>d("alerts").then(e=>(a(e),s(""),e)).catch(e=>(s(e.message),null)),[]);(0,l.useEffect)(()=>(_(),()=>{g.current&&clearInterval(g.current)}),[_]);const y=async t=>{r("prefs");try{a(await d("alerts/prefs",t))}catch(t){e(t.message,"bad")}finally{r("")}},v=t?.telegram.chats??[],k=!!t&&(t.prefs.telegram&&v.length>0||t.prefs.email&&t.emails.length>0);return(0,l.createElement)(E,{title:(0,i.__)("Alerts","digimail-smtp"),aside:t?k?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("On","digimail-smtp")):(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Off","digimail-smtp")):null},n&&(0,l.createElement)("p",{className:"dms-error"},n),!t&&!n&&(0,l.createElement)("div",{className:"dms-skel",style:{height:120}}),t&&(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("DigiMail tells you when emails fail, the quota is nearly used up, bounces or spam reports rise, the plugin stops reporting, forms are hit by bots, or something changes with your domain. The same problem is repeated at most once a day.","digimail-smtp")),(0,l.createElement)(b,{checked:t.prefs.telegram,disabled:"prefs"===m||!t.telegram.available,onChange:e=>y({...t.prefs,telegram:e}),label:(0,i.__)("Telegram","digimail-smtp"),hint:t.telegram.available?v.length?(0,i.sprintf)(/* translators: %s: number of chats. */ /* translators: %s: number of chats. */(0,i._n)("Sent to %s connected chat.","Sent to %s connected chats.",v.length,"digimail-smtp"),o(v.length)):(0,i.sprintf)(/* translators: %s: bot username. */ /* translators: %s: bot username. */(0,i.__)("Connect your Telegram (or a group) to the %s bot.","digimail-smtp"),t.telegram.bot??""):(0,i.__)("Telegram alerts are not available yet.","digimail-smtp")}),t.telegram.available&&(0,l.createElement)("div",{className:"dms-chats"},v.map(t=>(0,l.createElement)("div",{key:t.id,className:"dms-chat"},(0,l.createElement)(w,{name:"private"===t.kind?"send":"users",size:15}),(0,l.createElement)("span",{className:"dms-grow"},t.title,"private"!==t.kind&&(0,l.createElement)("span",{className:"dms-muted dms-small"}," · ",(0,i.__)("group","digimail-smtp"))),(0,l.createElement)(f,{size:"sm",variant:"ghost",busy:m===t.id,onClick:()=>(async t=>{r(t.id);try{a(await d("alerts/telegram/remove",{id:t.id}))}catch(t){e(t.message,"bad")}finally{r("")}})(t)},(0,i.__)("Remove","digimail-smtp")))),(0,l.createElement)("div",{className:"dms-actions"},(0,l.createElement)(f,{size:"sm",busy:"link"===m,onClick:async()=>{r("link");try{const a=await d("alerts/telegram",{});u(a),window.open(a.start_url,"_blank","noopener");const l=t?.telegram.chats.length??0;let n=0;g.current&&clearInterval(g.current),g.current=setInterval(async()=>{n++;const t=await _();(t&&t.telegram.chats.length>l||n>40)&&(g.current&&clearInterval(g.current),t&&t.telegram.chats.length>l&&(u(null),e((0,i.__)("Telegram connected.","digimail-smtp"))))},3e3)}catch(t){e(t.message,"bad")}finally{r("")}}},v.length?(0,i.__)("Connect another Telegram","digimail-smtp"):(0,i.__)("Connect Telegram","digimail-smtp"))),c&&(0,l.createElement)("div",{className:"dms-cf"},(0,l.createElement)("strong",null,(0,i.__)("Finish in Telegram","digimail-smtp")),(0,l.createElement)("span",{className:"dms-small"},(0,i.sprintf)(/* translators: %s: bot username. */ /* translators: %s: bot username. */(0,i.__)("Telegram opens a chat with %s: press Start. This page updates by itself once it is connected.","digimail-smtp"),c.bot)),(0,l.createElement)("div",{className:"dms-actions"},(0,l.createElement)("a",{className:"dms-btn dms-btn-secondary dms-btn-sm",href:c.start_url,target:"_blank",rel:"noreferrer"},(0,i.__)("Open Telegram","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:13})),(0,l.createElement)("a",{className:"dms-btn dms-btn-ghost dms-btn-sm",href:c.group_url,target:"_blank",rel:"noreferrer"},(0,i.__)("Add to a group instead","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:13}))),(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,i.__)("The link works once and expires in 30 minutes.","digimail-smtp")))),(0,l.createElement)(b,{checked:t.prefs.email,disabled:"prefs"===m,onChange:e=>y({...t.prefs,email:e}),label:(0,i.__)("Email","digimail-smtp"),hint:(0,i.sprintf)(/* translators: %s: email addresses. */ /* translators: %s: email addresses. */(0,i.__)("To %s (the users of your DigiMail account).","digimail-smtp"),t.emails.join(", "))}), (0,l.createElement)("div",null,(0,l.createElement)(f,{variant:"secondary",size:"sm",busy:"test"===m,disabled:!k,onClick:async()=>{r("test");try{const t=await d("alerts/test",{});e(t.telegram+t.email>0?(0,i.sprintf)(/* translators: 1: Telegram chats, 2: email addresses. */ /* translators: 1: Telegram chats, 2: email addresses. */(0,i.__)("Test alert sent: %1$s Telegram, %2$s email.","digimail-smtp"),o(t.telegram),o(t.email)):(0,i.__)("Nothing was sent: turn on email or connect Telegram first.","digimail-smtp"),t.telegram+t.email>0?"ok":"bad"),_()}catch(t){e(t.message,"bad")}finally{r("")}}},(0,l.createElement)(w,{name:"bell",size:14})," ",(0,i.__)("Send a test alert","digimail-smtp"))),t.recent.length>0&&(0,l.createElement)("div",{className:"dms-recent"},(0,l.createElement)("strong",{className:"dms-small"},(0,i.__)("Recent alerts","digimail-smtp")),(0,l.createElement)("ul",null,t.recent.slice(0,5).map(e=>(0,l.createElement)("li",{key:e.created_at+e.kind,title:e.body},(0,l.createElement)(h,{tone:Y[e.level]},p(e.created_at))," ",e.title))))))}function Q({state:e,setState:t}){const a=C(),[n,s]=(0,l.useState)(e.settings),[m,r]=(0,l.useState)(null),c=e.status.sender,o=c?.verified_domains??[],[p,u]=(0,l.useState)("domain"===c?.mode?c.email:""),[g,_]=(0,l.useState)(e.site.user_email),k=JSON.stringify(n)!==JSON.stringify(e.settings),N=async(e,l=(0,i.__)("Settings saved.","digimail-smtp"))=>{r("save");try{const i=await d("settings",e??n);return t(i),s(i.settings),a(l),!0}catch(e){return a(e.message,"bad"),!1}finally{r(null)}},S=Object.entries(e.controls).reduce((e,[t,a])=>((e[a.group]=e[a.group]??[]).push([t,a]),e),{}),M=n.backup,T=e=>s({...n,backup:{...M,...e}});return(0,l.createElement)("div",{className:"dms-grid-main"},(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)(E,{title:(0,i.__)("Sender","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(y,{label:(0,i.__)("Sender name","digimail-smtp"),htmlFor:"dms-name",hint:(0,i.__)("Leave empty to use the website name. Recipients see this name in their inbox.","digimail-smtp")},(0,l.createElement)("input",{id:"dms-name",value:n.from_name,placeholder:c?.name??e.site.name,onChange:e=>s({...n,from_name:e.target.value})})),(0,l.createElement)(b,{checked:n.force_from_name,onChange:e=>s({...n,force_from_name:e}),label:(0,i.__)("Always use this name","digimail-smtp"),hint:(0,i.__)("Even when another plugin (WooCommerce, a contact form) sets its own sender name.","digimail-smtp")}),(0,l.createElement)(y,{label:(0,i.__)("Sender email","digimail-smtp"),htmlFor:"dms-from",hint:o.length?(0,i.__)("Only addresses on domains verified in DigiMail can be used.","digimail-smtp"):(0,i.__)("Verify your domain on digimail.vn to send from your company email.","digimail-smtp")},o.length?(0,l.createElement)("select",{id:"dms-from",value:p,onChange:e=>u(e.target.value)},(0,l.createElement)("option",{value:""},(0,i.sprintf)(/* translators: %s: email address chosen automatically. */ /* translators: %s: email address chosen automatically. */24 (0,i.__)("%1$s of %2$s required DNS records are correct.","digimail-smtp"),o(n.dns.summary.ok_required),o(n.dns.summary.required))," ",n.dns.summary.dns_ready?(0,i.__)("DNS is ready: DigiMail confirms the domain within a few minutes, then the website switches to it by itself.","digimail-smtp"):(0,i.__)("Add the records below where your domain’s DNS is managed. Changes usually show within minutes, sometimes a few hours.","digimail-smtp")),z&&!n.dns.summary.dns_ready&&(0,l.createElement)("div",{className:"dms-cf"},(0,l.createElement)("strong",null,(0,i.__)("Add them automatically through Cloudflare","digimail-smtp")),$?(0,l.createElement)("div",null,(0,l.createElement)(f,{busy:"cf"===c,onClick:T},(0,i.__)("Add records in Cloudflare","digimail-smtp"))):(0,l.createElement)(l.Fragment,null,(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,l.createInterpolateElement)((0,i.__)("<a>Create a Cloudflare API token</a> (the link fills in the right permissions: Zone Read, DNS Edit), then paste it here. DigiMail stores it encrypted and only uses it to add these records.","digimail-smtp"),{a:(0,l.createElement)("a",{href:P,target:"_blank",rel:"noreferrer"})})),(0,l.createElement)("div",{className:"dms-row"},(0,l.createElement)("input",{type:"password",autoComplete:"off",value:u,onChange:e=>g(e.target.value),placeholder:(0,i.__)("Cloudflare API token","digimail-smtp"),"aria-label":(0,i.__)("Cloudflare API token","digimail-smtp")}),(0,l.createElement)(f,{busy:"cf"===c,disabled:u.trim().length<20,onClick:T},(0,i.__)("Connect and add records","digimail-smtp"))))),x&&!z&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: 1: DNS provider, 2: how to add records there. */ /* translators: 1: DNS provider, 2: how to add records there. */(0,i.__)("DNS is at <strong>%1$s</strong>. %2$s","digimail-smtp"),x.provider.name,x.provider.guide),{strong:(0,l.createElement)("strong",null)}),x.provider.url&&(0,l.createElement)(l.Fragment,null," ",(0,l.createElement)("a",{href:x.provider.url,target:"_blank",rel:"noreferrer"},(0,i.__)("Open","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:12})))),n.applied&&n.applied.problems>0&&(0,l.createElement)(v,{tone:"wait",title:(0,i.__)("Some records were left alone in Cloudflare","digimail-smtp")},(0,l.createElement)("ul",{className:"dms-reasons"},n.applied.outcomes.filter(e=>"conflict"===e.action||"failed"===e.action).map(e=>(0,l.createElement)("li",{key:e.name+e.type},e.type," ",e.name,": ",e.message)))),(0,l.createElement)("div",{className:"dms-table-wrap"},(0,l.createElement)("table",{className:"dms-table dms-dns"},(0,l.createElement)("thead",null,(0,l.createElement)("tr",null,(0,l.createElement)("th",null,(0,i.__)("Type","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Name (host)","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Value","digimail-smtp")),(0,l.createElement)("th",null,(0,i.__)("Status","digimail-smtp")))),(0,l.createElement)("tbody",null,n.dns.records.map(e=>(0,l.createElement)("tr",{key:e.type+e.name+e.value},(0,l.createElement)("td",null,(0,l.createElement)("strong",null,e.type),!e.required&&(0,l.createElement)("div",{className:"dms-small dms-muted"},(0,i.__)("recommended","digimail-smtp"))),(0,l.createElement)("td",null,(0,l.createElement)(H,{text:e.host||"@",label:(0,i.__)("name","digimail-smtp")})),(0,l.createElement)("td",null,(0,l.createElement)(H,{text:e.value,label:(0,i.__)("value","digimail-smtp")}),null!==e.priority&&(0,l.createElement)("div",{className:"dms-small dms-muted"},(0,i.sprintf)(/* translators: %s: MX priority. */ /* translators: %s: MX priority. */(0,i.__)("Priority: %s","digimail-smtp"),e.priority)),"CNAME"===e.type&&z&&(0,l.createElement)("div",{className:"dms-small dms-muted"},(0,i.__)("Proxy off (DNS only)","digimail-smtp"))),(0,l.createElement)("td",null,(0,l.createElement)(h,{tone:G[e.state].tone},G[e.state].label),"ok"!==e.state&&e.note&&(0,l.createElement)("div",{className:"dms-small dms-muted"},e.note))))))),(0,l.createElement)("div",{className:"dms-actions"},(0,l.createElement)(f,{busy:"check"===c,onClick:()=>M("check","domain/check")},(0,l.createElement)(w,{name:"refresh",size:15})," ",(0,i.__)("Check again","digimail-smtp")),(0,l.createElement)(f,{variant:"secondary",busy:"zone"===c,onClick:async()=>{p("zone");try{const e=await d("domain/zonefile"),t=URL.createObjectURL(new Blob([e.text],{type:"text/plain;charset=utf-8"})),a=document.createElement("a");a.href=t,a.download=`digimail-${n?.dns?.domain??"dns"}.txt`,a.click(),URL.revokeObjectURL(t)}catch(e){a(e.message,"bad")}finally{p("")}}},(0,l.createElement)(w,{name:"download",size:15})," ",(0,i.__)("Download zone file","digimail-smtp"))),(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("When the domain is verified, DigiMail tells you by Telegram or email (see Alerts).","digimail-smtp"))))}const Y={bad:"bad",warn:"wait",good:"ok"};function J(){const e=C(),[t,a]=(0,l.useState)(null),[n,s]=(0,l.useState)(""),[m,r]=(0,l.useState)(""),[c,u]=(0,l.useState)(null),g=(0,l.useRef)(null),_=(0,l.useCallback)(()=>d("alerts").then(e=>(a(e),s(""),e)).catch(e=>(s(e.message),null)),[]);(0,l.useEffect)(()=>(_(),()=>{g.current&&clearInterval(g.current)}),[_]);const y=async t=>{r("prefs");try{a(await d("alerts/prefs",t))}catch(t){e(t.message,"bad")}finally{r("")}},v=t?.telegram.chats??[],k=!!t&&(t.prefs.telegram&&v.length>0||t.prefs.email&&t.emails.length>0);return(0,l.createElement)(E,{title:(0,i.__)("Alerts","digimail-smtp"),aside:t?k?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("On","digimail-smtp")):(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Off","digimail-smtp")):null},n&&(0,l.createElement)("p",{className:"dms-error"},n),!t&&!n&&(0,l.createElement)("div",{className:"dms-skel",style:{height:120}}),t&&(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("DigiMail tells you when emails fail, the quota is nearly used up, bounces or spam reports rise, the plugin stops reporting, forms are hit by bots, or something changes with your domain. The same problem is repeated at most once a day.","digimail-smtp")),(0,l.createElement)(b,{checked:t.prefs.telegram,disabled:"prefs"===m||!t.telegram.available,onChange:e=>y({...t.prefs,telegram:e}),label:(0,i.__)("Telegram","digimail-smtp"),hint:t.telegram.available?v.length?(0,i.sprintf)(/* translators: %s: number of chats. */ /* translators: %s: number of chats. */(0,i._n)("Sent to %s connected chat.","Sent to %s connected chats.",v.length,"digimail-smtp"),o(v.length)):(0,i.sprintf)(/* translators: %s: bot username. */ /* translators: %s: bot username. */(0,i.__)("Connect your Telegram (or a group) to the %s bot.","digimail-smtp"),t.telegram.bot??""):(0,i.__)("Telegram alerts are not available yet.","digimail-smtp")}),t.telegram.available&&(0,l.createElement)("div",{className:"dms-chats"},v.map(t=>(0,l.createElement)("div",{key:t.id,className:"dms-chat"},(0,l.createElement)(w,{name:"private"===t.kind?"send":"users",size:15}),(0,l.createElement)("span",{className:"dms-grow"},t.title,"private"!==t.kind&&(0,l.createElement)("span",{className:"dms-muted dms-small"}," · ",(0,i.__)("group","digimail-smtp"))),(0,l.createElement)(f,{size:"sm",variant:"ghost",busy:m===t.id,onClick:()=>(async t=>{r(t.id);try{a(await d("alerts/telegram/remove",{id:t.id}))}catch(t){e(t.message,"bad")}finally{r("")}})(t)},(0,i.__)("Remove","digimail-smtp")))),(0,l.createElement)("div",{className:"dms-actions"},(0,l.createElement)(f,{size:"sm",busy:"link"===m,onClick:async()=>{r("link");try{const a=await d("alerts/telegram",{});u(a),window.open(a.start_url,"_blank","noopener");const l=t?.telegram.chats.length??0;let n=0;g.current&&clearInterval(g.current),g.current=setInterval(async()=>{n++;const t=await _();(t&&t.telegram.chats.length>l||n>40)&&(g.current&&clearInterval(g.current),t&&t.telegram.chats.length>l&&(u(null),e((0,i.__)("Telegram connected.","digimail-smtp"))))},3e3)}catch(t){e(t.message,"bad")}finally{r("")}}},v.length?(0,i.__)("Connect another Telegram","digimail-smtp"):(0,i.__)("Connect Telegram","digimail-smtp"))),c&&(0,l.createElement)("div",{className:"dms-cf"},(0,l.createElement)("strong",null,(0,i.__)("Finish in Telegram","digimail-smtp")),(0,l.createElement)("span",{className:"dms-small"},(0,i.sprintf)(/* translators: %s: bot username. */ /* translators: %s: bot username. */(0,i.__)("Telegram opens a chat with %s: press Start. This page updates by itself once it is connected.","digimail-smtp"),c.bot)),(0,l.createElement)("div",{className:"dms-actions"},(0,l.createElement)("a",{className:"dms-btn dms-btn-secondary dms-btn-sm",href:c.start_url,target:"_blank",rel:"noreferrer"},(0,i.__)("Open Telegram","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:13})),(0,l.createElement)("a",{className:"dms-btn dms-btn-ghost dms-btn-sm",href:c.group_url,target:"_blank",rel:"noreferrer"},(0,i.__)("Add to a group instead","digimail-smtp")," ",(0,l.createElement)(w,{name:"external",size:13}))),(0,l.createElement)("span",{className:"dms-small dms-muted"},(0,i.__)("The link works once and expires in 30 minutes.","digimail-smtp")))),(0,l.createElement)(b,{checked:t.prefs.email,disabled:"prefs"===m,onChange:e=>y({...t.prefs,email:e}),label:(0,i.__)("Email","digimail-smtp"),hint:(0,i.sprintf)(/* translators: %s: email addresses. */ /* translators: %s: email addresses. */(0,i.__)("To %s (the users of your DigiMail account).","digimail-smtp"),t.emails.join(", "))}),void 0!==t.prefs.weekly&&(0,l.createElement)(b,{checked:t.prefs.weekly,disabled:"prefs"===m,onChange:e=>y({...t.prefs,weekly:e}),label:(0,i.__)("Weekly summary by email","digimail-smtp"),hint:(0,i.__)("Every Monday morning: emails sent last week, delivery rate, spam blocked on each website and the month’s quota. Nothing is sent after a quiet week.","digimail-smtp")}),(0,l.createElement)("div",null,(0,l.createElement)(f,{variant:"secondary",size:"sm",busy:"test"===m,disabled:!k,onClick:async()=>{r("test");try{const t=await d("alerts/test",{});e(t.telegram+t.email>0?(0,i.sprintf)(/* translators: 1: Telegram chats, 2: email addresses. */ /* translators: 1: Telegram chats, 2: email addresses. */(0,i.__)("Test alert sent: %1$s Telegram, %2$s email.","digimail-smtp"),o(t.telegram),o(t.email)):(0,i.__)("Nothing was sent: turn on email or connect Telegram first.","digimail-smtp"),t.telegram+t.email>0?"ok":"bad"),_()}catch(t){e(t.message,"bad")}finally{r("")}}},(0,l.createElement)(w,{name:"bell",size:14})," ",(0,i.__)("Send a test alert","digimail-smtp"))),t.recent.length>0&&(0,l.createElement)("div",{className:"dms-recent"},(0,l.createElement)("strong",{className:"dms-small"},(0,i.__)("Recent alerts","digimail-smtp")),(0,l.createElement)("ul",null,t.recent.slice(0,5).map(e=>(0,l.createElement)("li",{key:e.created_at+e.kind,title:e.body},(0,l.createElement)(h,{tone:Y[e.level]},p(e.created_at))," ",e.title))))))}function Q({state:e,setState:t}){const a=C(),[n,s]=(0,l.useState)(e.settings),[m,r]=(0,l.useState)(null),c=e.status.sender,o=c?.verified_domains??[],[p,u]=(0,l.useState)("domain"===c?.mode?c.email:""),[g,_]=(0,l.useState)(e.site.user_email),k=JSON.stringify(n)!==JSON.stringify(e.settings),N=async(e,l=(0,i.__)("Settings saved.","digimail-smtp"))=>{r("save");try{const i=await d("settings",e??n);return t(i),s(i.settings),a(l),!0}catch(e){return a(e.message,"bad"),!1}finally{r(null)}},S=Object.entries(e.controls).reduce((e,[t,a])=>((e[a.group]=e[a.group]??[]).push([t,a]),e),{}),M=n.backup,T=e=>s({...n,backup:{...M,...e}});return(0,l.createElement)("div",{className:"dms-grid-main"},(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)(E,{title:(0,i.__)("Sender","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(y,{label:(0,i.__)("Sender name","digimail-smtp"),htmlFor:"dms-name",hint:(0,i.__)("Leave empty to use the website name. Recipients see this name in their inbox.","digimail-smtp")},(0,l.createElement)("input",{id:"dms-name",value:n.from_name,placeholder:c?.name??e.site.name,onChange:e=>s({...n,from_name:e.target.value})})),(0,l.createElement)(b,{checked:n.force_from_name,onChange:e=>s({...n,force_from_name:e}),label:(0,i.__)("Always use this name","digimail-smtp"),hint:(0,i.__)("Even when another plugin (WooCommerce, a contact form) sets its own sender name.","digimail-smtp")}),(0,l.createElement)(y,{label:(0,i.__)("Sender email","digimail-smtp"),htmlFor:"dms-from",hint:o.length?(0,i.__)("Only addresses on domains verified in DigiMail can be used.","digimail-smtp"):(0,i.__)("Verify your domain on digimail.vn to send from your company email.","digimail-smtp")},o.length?(0,l.createElement)("select",{id:"dms-from",value:p,onChange:e=>u(e.target.value)},(0,l.createElement)("option",{value:""},(0,i.sprintf)(/* translators: %s: email address chosen automatically. */ /* translators: %s: email address chosen automatically. */ 25 25 (0,i.__)("Automatic (%s)","digimail-smtp"),"domain"===c?.mode?c.email:`noreply@${o[0]}`)),o.flatMap(e=>["noreply","thongbao","lienhe","hotro","donhang"].map(t=>`${t}@${e}`)).map(e=>(0,l.createElement)("option",{key:e,value:e},e)),p&&!o.flatMap(e=>["noreply","thongbao","lienhe","hotro","donhang"].map(t=>`${t}@${e}`)).includes(p)&&(0,l.createElement)("option",{value:p},p)):(0,l.createElement)("div",{className:"dms-readonly"},c?.email," ",(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Shared address","digimail-smtp")))),"shared"===c?.mode&&(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: %s: reply-to email address. */ /* translators: %s: reply-to email address. */(0,i.__)("Replies go to <strong>%s</strong>.","digimail-smtp"),c.reply_to??e.site.admin_email),{strong:(0,l.createElement)("strong",null)})),(0,l.createElement)("div",null,(0,l.createElement)(f,{busy:"sender"===m,onClick:async()=>{r("sender");try{const e=await d("sender",{from_email:p,from_name:n.from_name});t(e),await N({from_name:n.from_name,force_from_name:n.force_from_name},(0,i.__)("Sender saved.","digimail-smtp"))}catch(e){a(e.message,"bad")}finally{r(null)}}},(0,i.__)("Save sender","digimail-smtp"))))),(0,l.createElement)(K,{state:e,setState:t}),(0,l.createElement)(J,null),(0,l.createElement)(E,{title:(0,i.__)("Sending email","digimail-smtp")},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)(b,{checked:n.queue,onChange:e=>s({...n,queue:e}),label:(0,i.__)("Background sending","digimail-smtp"),hint:(0,i.__)("Checkout and contact forms do not wait for email: messages are queued and sent right after. Recommended for online shops.","digimail-smtp")}),n.queue&&!e.env.cron&&(0,l.createElement)(v,{tone:"wait"},(0,l.createInterpolateElement)((0,i.__)("WP-Cron is off (DISABLE_WP_CRON). A server cron job must call wp-cron.php every minute, or run <code>wp digimail queue</code>.","digimail-smtp"),{code:(0,l.createElement)("code",null)})))),(0,l.createElement)(A,{state:e,s:n,setS:s}),(0,l.createElement)(U,{state:e,s:n,setS:s}),(0,l.createElement)(E,{title:(0,i.__)("Backup connection","digimail-smtp"),aside:M.enabled?(0,l.createElement)(h,{tone:"ok"},(0,i.__)("On","digimail-smtp")):(0,l.createElement)(h,null,(0,i.__)("Off","digimail-smtp"))},(0,l.createElement)("div",{className:"dms-form"},(0,l.createElement)("p",{className:"dms-muted dms-small"},(0,i.__)("When DigiMail cannot send (network down, quota used up), the plugin sends through this SMTP server so no email is lost. Your hosting SMTP, Gmail or Microsoft 365 all work.","digimail-smtp")),(0,l.createElement)(b,{checked:M.enabled,onChange:e=>T({enabled:e}),label:(0,i.__)("Turn on backup connection","digimail-smtp")}),M.enabled&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("div",{className:"dms-two"},(0,l.createElement)(y,{label:(0,i.__)("SMTP server","digimail-smtp"),htmlFor:"dms-bh"},(0,l.createElement)("input",{id:"dms-bh",value:M.host,onChange:e=>T({host:e.target.value}),placeholder:"smtp.gmail.com"})),(0,l.createElement)(y,{label:(0,i.__)("Port","digimail-smtp"),htmlFor:"dms-bp"},(0,l.createElement)("input",{id:"dms-bp",type:"number",value:M.port,onChange:e=>T({port:Number(e.target.value)})}))),(0,l.createElement)("div",{className:"dms-field"},(0,l.createElement)("span",{className:"dms-label"},(0,i.__)("Encryption","digimail-smtp")),(0,l.createElement)("div",{className:"dms-seg"},[["tls","TLS (587)"],["ssl","SSL (465)"],["none",(0,i.__)("None","digimail-smtp")]].map(([e,t])=>(0,l.createElement)("button",{key:e,type:"button",className:M.encryption===e?"is-on":"",onClick:()=>T({encryption:e,port:"ssl"===e?465:"tls"===e?587:25})},t)))),(0,l.createElement)("div",{className:"dms-two"},(0,l.createElement)(y,{label:(0,i.__)("Username","digimail-smtp"),htmlFor:"dms-bu"},(0,l.createElement)("input",{id:"dms-bu",value:M.username,autoComplete:"off",onChange:e=>T({username:e.target.value})})),(0,l.createElement)(y,{label:(0,i.__)("Password","digimail-smtp"),htmlFor:"dms-bpw",hint:(0,i.__)("Encrypted when saved.","digimail-smtp")},(0,l.createElement)("input",{id:"dms-bpw",type:"password",autoComplete:"new-password",value:M.password,onChange:e=>T({password:e.target.value})}))),(0,l.createElement)(y,{label:(0,i.__)("From email on this server","digimail-smtp"),htmlFor:"dms-bf",hint:(0,i.__)("Leave empty to use the SMTP username.","digimail-smtp")},(0,l.createElement)("input",{id:"dms-bf",type:"email",value:M.from_email,onChange:e=>T({from_email:e.target.value})})),(0,l.createElement)("div",{className:"dms-inline"},(0,l.createElement)("input",{type:"email","aria-label":(0,i.__)("Send a test email to","digimail-smtp"),value:g,onChange:e=>_(e.target.value)}),(0,l.createElement)(f,{variant:"secondary",busy:"backup"===m,onClick:async()=>{if(!k||await N()){r("backup");try{await d("backup/test",{to:g}),a((0,i.sprintf)(/* translators: %s: email address. */ /* translators: %s: email address. */(0,i.__)("The backup server sent an email to %s.","digimail-smtp"),g))}catch(e){a(e.message,"bad")}finally{r(null)}}}},(0,i.__)("Save and send test","digimail-smtp")))))),(0,l.createElement)(E,{title:(0,i.__)("Turn off WordPress default emails","digimail-smtp")},(0,l.createElement)("p",{className:"dms-muted dms-small"},(0,i.__)("Fewer unneeded emails for administrators. Order emails, contact forms and password resets are not affected.","digimail-smtp")),Object.entries(S).map(([e,t])=>(0,l.createElement)("div",{key:e,className:"dms-group"},(0,l.createElement)("h3",null,e),t.map(([e,t])=>(0,l.createElement)(b,{key:e,checked:!1!==n.controls[e],onChange:t=>{const a={...n.controls};t?delete a[e]:a[e]=!1,s({...n,controls:a})},label:t.label,hint:t.hint||void 0})))))),(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)("div",{className:"dms-sticky"},(0,l.createElement)(E,{title:(0,i.__)("Save changes","digimail-smtp")},(0,l.createElement)("p",{className:"dms-muted dms-small"},k?(0,i.__)("You have unsaved changes.","digimail-smtp"):(0,i.__)("All changes are saved.","digimail-smtp")),(0,l.createElement)(f,{size:"block",busy:"save"===m,disabled:!k,onClick:()=>N()},(0,i.__)("Save settings","digimail-smtp"))),(0,l.createElement)(E,{title:(0,i.__)("Connection","digimail-smtp")},(0,l.createElement)("dl",{className:"dms-dl"},(0,l.createElement)("dt",null,(0,i.__)("Website","digimail-smtp")),(0,l.createElement)("dd",null,e.status.site?.name),(0,l.createElement)("dt",null,(0,i.__)("Account","digimail-smtp")),(0,l.createElement)("dd",null,e.status.account?.name),(0,l.createElement)("dt",null,(0,i.__)("Key","digimail-smtp")),(0,l.createElement)("dd",null,e.token_constant?(0,i.__)("Set in wp-config.php","digimail-smtp"):(0,i.__)("Stored in the database","digimail-smtp"))),(0,l.createElement)(b,{checked:n.keep_data,onChange:e=>s({...n,keep_data:e}),label:(0,i.__)("Keep settings when the plugin is deleted","digimail-smtp")}),(0,l.createElement)(b,{checked:!!n.diagnostics,onChange:e=>s({...n,diagnostics:e}),label:(0,i.__)("Share diagnostics with DigiMail support","digimail-smtp"),hint:(0,i.__)("Off by default. When on, the WordPress, PHP and WooCommerce versions, language, a few of this plugin's settings and the names of other active email plugins are sent with the twice-daily status check, so support can see problems on digimail.vn.","digimail-smtp")}),!e.token_constant&&(0,l.createElement)(f,{variant:"danger",size:"block",busy:"disconnect"===m,onClick:async()=>{window.confirm((0,i.__)("Disconnect DigiMail? The website will go back to sending email through your hosting server (or the backup server, if set).","digimail-smtp"))&&(r("disconnect"),await d("disconnect",{}),window.location.reload())}},(0,l.createElement)(w,{name:"x",size:15})," ",(0,i.__)("Disconnect DigiMail","digimail-smtp"))))))}function Z({state:e,setState:t}){const a=C(),[n,s]=(0,l.useState)(null),m=e.conflicts.map(e=>e.name),r=[`DigiMail SMTP ${e.env.plugin}`,`WordPress ${e.env.wordpress}, PHP ${e.env.php}`,`Website: ${e.site.url}`,`Connected: ${e.connected?"yes":"no"}${e.revoked?" (revoked)":""}`,`From: ${e.status.sender?.email??"-"} (${e.status.sender?.mode??"-"})`,`Background sending: ${e.settings.queue?"on":"off"}, WP-Cron: ${e.env.cron?"on":"off"}`,`Backup: ${e.settings.backup.enabled?e.settings.backup.host:"off"}`,`Queue: ${e.queue.queued} waiting, ${e.queue.failed} failed`,`Other SMTP plugins: ${m.join(", ")||"none"}`].join("\n");return(0,l.createElement)("div",{className:"dms-grid-main"},(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)(E,{title:(0,i.__)("Switch from another SMTP plugin","digimail-smtp")},(0,l.createElement)("p",{className:"dms-muted dms-small"},(0,i.__)("Imports the sender name and the emails you turned off. The old SMTP server becomes the backup connection: DigiMail sends, and the old server is used only when DigiMail cannot.","digimail-smtp")),0===e.importable.length?(0,l.createElement)(k,{title:(0,i.__)("No settings found to import","digimail-smtp")},(0,i.__)("Supports WP Mail SMTP, Easy WP SMTP, Post SMTP, FluentSMTP and SMTP Mailer.","digimail-smtp")):(0,l.createElement)("ul",{className:"dms-list"},e.importable.map(e=>(0,l.createElement)("li",{key:e.key},(0,l.createElement)("span",null,(0,l.createElement)("strong",null,e.name),m.includes(e.name)&&(0,l.createElement)(h,{tone:"wait"},(0,i.__)("Active","digimail-smtp")),(0,l.createElement)("small",null,e.smtp?(0,i.__)("Has an SMTP server to use as backup","digimail-smtp"):(0,i.__)("Sender name only","digimail-smtp"))),(0,l.createElement)(f,{variant:"secondary",size:"sm",busy:n===e.key,onClick:()=>(async(e,l)=>{s(e);try{const n=await d("import",{from:e});t(n),a(n.settings.backup.host?(0,i.sprintf)(/* translators: %s: plugin name. */ /* translators: %s: plugin name. */(0,i.__)("Settings imported from %s. The old SMTP server is now the backup connection.","digimail-smtp"),l):(0,i.sprintf)(/* translators: %s: plugin name. */ /* translators: %s: plugin name. */(0,i.__)("Settings imported from %s.","digimail-smtp"),l))}catch(e){a(e.message,"bad")}finally{s(null)}})(e.key,e.name)},(0,i.__)("Import","digimail-smtp"))))),m.length>0&&(0,l.createElement)("p",{className:"dms-small"},(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: %s: plugin names. */ /* translators: %s: plugin names. */(0,i.__)("After importing, deactivate %s on the <a>Plugins page</a> so the two plugins do not both try to send email.","digimail-smtp"),m.join(", ")),{a:(0,l.createElement)("a",{href:"plugins.php"})}))),(0,l.createElement)(E,{title:(0,i.__)("Command line (WP-CLI)","digimail-smtp")},(0,l.createElement)("pre",{className:"dms-pre"},[`wp digimail status # ${(0,i.__)("connection, sender, quota","digimail-smtp")}`,`wp digimail test you@company.com # ${(0,i.__)("send a test email","digimail-smtp")}`,`wp digimail queue --retry-failed # ${(0,i.__)("resend waiting and failed emails","digimail-smtp")}`,"wp digimail connect you@company.com","wp digimail disconnect"].join("\n")),(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("Agencies can set the key in wp-config.php:","digimail-smtp")," ",(0,l.createElement)("code",null,"define( 'DIGIMAIL_SMTP_TOKEN', 'dm_…' );")))),(0,l.createElement)("div",{className:"dms-col"},(0,l.createElement)(E,{title:(0,i.__)("Support information","digimail-smtp"),aside:(0,l.createElement)(f,{variant:"ghost",size:"sm",onClick:()=>{navigator.clipboard?.writeText(r),a((0,i.__)("Copied.","digimail-smtp"))}},(0,l.createElement)(w,{name:"download",size:14})," ",(0,i.__)("Copy","digimail-smtp"))},(0,l.createElement)("pre",{className:"dms-pre"},r),(0,l.createElement)("p",{className:"dms-small dms-muted"},(0,i.__)("Send this when you contact DigiMail support. It contains no secret keys.","digimail-smtp")))))}const X=[{key:"overview",label:(0,i.__)("Overview","digimail-smtp"),icon:"chart"},{key:"logs",label:(0,i.__)("Email log","digimail-smtp"),icon:"list"},{key:"contacts",label:(0,i.__)("Customers","digimail-smtp"),icon:"users"},{key:"test",label:(0,i.__)("Test email","digimail-smtp"),icon:"send"},{key:"settings",label:(0,i.__)("Settings","digimail-smtp"),icon:"settings"},{key:"tools",label:(0,i.__)("Tools","digimail-smtp"),icon:"tools"}],ee=()=>{const e=window.location.hash.replace("#","");return X.some(t=>t.key===e)?e:"overview"},te=document.getElementById("digimail-smtp-app");if(te){const e=(0,l.createElement)(function({children:e}){const[t,a]=(0,l.useState)([]),i=(0,l.useCallback)((e,t="ok")=>{const l=Date.now()+Math.random();a(a=>[...a,{id:l,msg:e,tone:t}]),setTimeout(()=>a(e=>e.filter(e=>e.id!==l)),4500)},[]);return(0,l.createElement)(S.Provider,{value:i},e,(0,l.createElement)("div",{className:"dms-toasts",role:"status","aria-live":"polite"},t.map(e=>(0,l.createElement)("div",{key:e.id,className:`dms-toast dms-toast-${e.tone}`},(0,l.createElement)(w,{name:"ok"===e.tone?"check":"alert",size:16}),e.msg))))},null,(0,l.createElement)(function(){const e=C(),[t,a]=(0,l.useState)(null),[n,s]=(0,l.useState)(""),[m,r]=(0,l.useState)(ee),[c,o]=(0,l.useState)(!1),p=(0,l.useCallback)(async(e=!1)=>{try{a(await d("state"+(e?"?refresh=1":""))),s("")}catch(e){s(e.message)}},[]);(0,l.useEffect)(()=>{p();const t=window.digimailSmtp?.flash;t&&e(t.message,t.ok?"ok":"bad")},[p,e]),(0,l.useEffect)(()=>{const e=()=>r(ee());return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)},[]);const u=e=>{window.location.hash=e,r(e),window.scrollTo({top:0})};if(n&&!t)return(0,l.createElement)("div",{className:"dms"},(0,l.createElement)(v,{tone:"bad",title:(0,i.__)("DigiMail SMTP could not load","digimail-smtp")},n));if(!t)return(0,l.createElement)("div",{className:"dms"},(0,l.createElement)("div",{className:"dms-skel",style:{height:420}}));if(!t.connected)return(0,l.createElement)("div",{className:"dms"},(0,l.createElement)(T,{state:t,reload:async()=>{await p(!0),o(!0),u("overview")}}));const g=t.status.sender;return(0,l.createElement)("div",{className:"dms"},(0,l.createElement)("header",{className:"dms-top"},(0,l.createElement)("div",{className:"dms-brand"},(0,l.createElement)("img",{src:window.digimailSmtp?.logo,alt:"",width:30,height:30}),(0,l.createElement)("div",null,(0,l.createElement)("strong",null,"DigiMail SMTP"),(0,l.createElement)("span",null,t.revoked?(0,l.createElement)(h,{tone:"bad"},(0,i.__)("Disconnected","digimail-smtp")):(0,l.createElement)(h,{tone:"ok"},(0,i._x)("Active","connection status","digimail-smtp"))))),(0,l.createElement)("nav",{className:"dms-tabs","aria-label":"DigiMail SMTP"},X.map(e=>(0,l.createElement)("a",{key:e.key,href:`#${e.key}`,className:m===e.key?"is-on":"","aria-current":m===e.key?"page":void 0,onClick:t=>{t.preventDefault(),u(e.key)}},(0,l.createElement)(w,{name:e.icon,size:16}),e.label,"logs"===e.key&&t.queue.failed>0&&(0,l.createElement)("span",{className:"dms-count"},t.queue.failed))))),t.revoked&&(0,l.createElement)(v,{tone:"bad",title:(0,i.__)("This website was disconnected on digimail.vn","digimail-smtp"),action:(0,l.createElement)(f,{onClick:async()=>{await d("disconnect",{}),p(!0)}},(0,i.__)("Reconnect","digimail-smtp"))},t.settings.backup.enabled?(0,i.__)("Email is not going through DigiMail. The backup server is sending it.","digimail-smtp"):(0,i.__)("Email is not going through DigiMail.","digimail-smtp")),c&&g&&(0,l.createElement)("div",{className:"dms-welcome"},(0,l.createElement)("div",{className:"dms-welcome-icon"},(0,l.createElement)(w,{name:"check",size:28})),(0,l.createElement)("div",null,(0,l.createElement)("h2",null,(0,i.__)("Done! This website can send email now.","digimail-smtp")),(0,l.createElement)("p",null,(0,l.createInterpolateElement)((0,i.sprintf)(/* translators: %s: sender email address. */ /* translators: %s: sender email address. */(0,i.__)("Email will be sent from <strong>%s</strong>. Send a test email to make sure everything works.","digimail-smtp"),g.email),{strong:(0,l.createElement)("strong",null)}))),(0,l.createElement)(f,{onClick:()=>{o(!1),u("test")}},(0,l.createElement)(w,{name:"send",size:16})," ",(0,i.__)("Send a test email","digimail-smtp")),(0,l.createElement)("button",{type:"button",className:"dms-icon-btn","aria-label":(0,i.__)("Close","digimail-smtp"),onClick:()=>o(!1)},(0,l.createElement)(w,{name:"x"}))),(0,l.createElement)("main",null,"overview"===m&&(0,l.createElement)($,{state:t,go:u}),"logs"===m&&(0,l.createElement)(j,{reload:()=>p()}),"contacts"===m&&(0,l.createElement)(B,{state:t,go:u}),"test"===m&&(0,l.createElement)(V,{state:t,go:u}),"settings"===m&&(0,l.createElement)(Q,{state:t,setState:a}),"tools"===m&&(0,l.createElement)(Z,{state:t,setState:a})),(0,l.createElement)("footer",{className:"dms-foot"},"DigiMail SMTP ",t.env.plugin," · ",(0,l.createElement)("a",{href:t.env.app,target:"_blank",rel:"noreferrer"},"digimail.vn")))},null));"function"==typeof l.createRoot?(0,l.createRoot)(te).render(e):(0,l.render)(e,te)}}};const t={};function a(l){const i=t[l];if(void 0!==i)return i.exports;const n=t[l]={exports:{}};return e[l](n,n.exports,a),n.exports}a.m=e,(()=>{const e=[];a.O=(t,l,i)=>{if(!l){for(var n=0;n<e.length;n++){let[l,i]=e[n],m=!0;for(var s=0;s<l.length;s++)a.O.j(l[s])?l.splice(s--,1):m=!1;if(m){e.splice(n--,1);const a=i();void 0!==a&&(t=a)}}return t}e.push([l,i])}})(),a.n=e=>{const t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var l in t)a.o(t,l)&&!a.o(e,l)&&Object.defineProperty(e,l,{enumerable:!0,get:t[l]})},a.o=(e,t)=>Object.hasOwn(e,t),(()=>{const e={57:0,350:0};a.O.j=t=>0===e[t];const t=(t,l)=>{let[i,n,s]=l;var m,r,d=0;if(i.some(t=>0!==e[t])){for(m in n)a.o(n,m)&&(a.m[m]=n[m]);if(s)var c=s(a)}for(t&&t(l);d<i.length;d++)r=i[d],a.o(e,r)&&e[r]&&e[r][0](),e[r]=0;return a.O(c)},l=Array.isArray(globalThis.webpackChunkdigimail_smtp)?globalThis.webpackChunkdigimail_smtp:globalThis.webpackChunkdigimail_smtp=[];l.forEach(t.bind(null,0)),l.push=t.bind(null,l.push.bind(l))})();let l=a.O(void 0,[350],()=>a(402));l=a.O(l)})(); -
digimail-smtp/trunk/digimail-smtp.php
r3829755 r3829867 4 4 * Plugin URI: https://digimail.vn 5 5 * Description: Send WordPress email without setting up SMTP: activate, enter your email, and your site sends mail right away. Email log with real delivery status, background sending, backup connection, email controls, and many sites managed on digimail.vn. 6 * Version: 2.5. 06 * Version: 2.5.1 7 7 * Requires at least: 6.2 8 8 * Requires PHP: 7.4 … … 20 20 } 21 21 22 define( 'DIGIMAIL_SMTP_VERSION', '2.5. 0' );22 define( 'DIGIMAIL_SMTP_VERSION', '2.5.1' ); 23 23 define( 'DIGIMAIL_SMTP_FILE', __FILE__ ); 24 24 define( 'DIGIMAIL_SMTP_DIR', plugin_dir_path( __FILE__ ) ); -
digimail-smtp/trunk/includes/Plugin.php
r3829755 r3829867 33 33 Admin::init(); 34 34 Widget::init(); 35 Review::init(); 35 36 } 36 37 if ( file_exists( __DIR__ . '/Updater.php' ) ) { -
digimail-smtp/trunk/includes/Queue.php
r3829755 r3829867 111 111 $r['ok'] = true; 112 112 } 113 if ( $r['ok'] ) { 114 Review::count(); 115 } 113 116 return array( 114 117 'ok' => $r['ok'], -
digimail-smtp/trunk/includes/Rest.php
r3829755 r3829867 698 698 'email' => (bool) $req->get_param( 'email' ), 699 699 'telegram' => (bool) $req->get_param( 'telegram' ), 700 ) 700 ) + ( null !== $req->get_param( 'weekly' ) ? array( 'weekly' => (bool) $req->get_param( 'weekly' ) ) : array() ) 701 701 ) 702 702 ); -
digimail-smtp/trunk/readme.txt
r3829755 r3829867 5 5 Tested up to: 7.1 6 6 Requires PHP: 7.4 7 Stable tag: 2.5. 07 Stable tag: 2.5.1 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 36 36 * Verify your own domain from the plugin: the DNS records to add with copy buttons and live status, one-click setup through Cloudflare, a zone file to import, and the plugin switches to your domain by itself once verified. 37 37 * Alerts by Telegram and email: failing emails, quota nearly used up, rising bounces or spam reports, a plugin that stopped reporting, forms hit by bots, domain verified or failing. 38 * Weekly summary by email every Monday: emails sent, delivery rate and spam blocked on each website, and the month's quota. Nothing is sent after a quiet week, and it can be turned off. 38 39 * Email to addresses typed by visitors is checked by DigiMail before it goes out (real address, domain that takes mail, not bounced before, not mailed too often), so bots cannot use your forms to send email to strangers. 39 40 * Email controls: turn off WordPress default notifications you do not need (new comments, new users, password changes, automatic updates). … … 116 117 == Changelog == 117 118 119 = 2.5.1 = 120 * Weekly summary email (on by default, can be turned off in Settings → Alerts). 121 * After 50 emails delivered, a one-time request to review the plugin on WordPress.org, on the Dashboard and the plugin screen only. 122 118 123 = 2.5.0 = 119 124 * Resend any email from the log, to its recipient or to another address. -
digimail-smtp/trunk/src/Alerts.tsx
r3829755 r3829867 11 11 type AlertsInfo = { 12 12 telegram: { available: boolean; bot: string | null; chats: Chat[] }; 13 prefs: { email: boolean; telegram: boolean };13 prefs: { email: boolean; telegram: boolean; weekly?: boolean }; 14 14 emails: string[]; 15 15 recent: Recent[]; … … 163 163 hint={ sprintf( /* translators: %s: email addresses. */ __( 'To %s (the users of your DigiMail account).', 'digimail-smtp' ), info.emails.join( ', ' ) ) } /> 164 164 165 { info.prefs.weekly !== undefined && ( 166 <Toggle checked={ info.prefs.weekly } disabled={ busy === 'prefs' } onChange={ ( v ) => prefs( { ...info.prefs, weekly: v } ) } 167 label={ __( 'Weekly summary by email', 'digimail-smtp' ) } 168 hint={ __( 'Every Monday morning: emails sent last week, delivery rate, spam blocked on each website and the month’s quota. Nothing is sent after a quiet week.', 'digimail-smtp' ) } /> 169 ) } 170 165 171 <div><Button variant="secondary" size="sm" busy={ busy === 'test' } disabled={ ! on } onClick={ test }><Icon name="bell" size={ 14 } /> { __( 'Send a test alert', 'digimail-smtp' ) }</Button></div> 166 172 -
digimail-smtp/trunk/uninstall.php
r3829755 r3829867 17 17 global $wpdb; 18 18 $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}digimail_smtp_queue" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 19 foreach ( array( 'digimail_smtp_settings', 'digimail_smtp_token', 'digimail_smtp_status', 'digimail_smtp_db', 'digimail_smtp_revoked', 'digimail_smtp_last_failure', 'digimail_smtp_imported', 'digimail_smtp_contacts', 'digimail_smtp_contacts_last', 'digimail_smtp_guard_log', 'digimail_smtp_guard_stats', 'digimail_smtp_guard_seen', 'digimail_smtp_guard_secret', 'digimail_smtp_guard_allow' ) as $digimail_smtp_option ) {19 foreach ( array( 'digimail_smtp_settings', 'digimail_smtp_token', 'digimail_smtp_status', 'digimail_smtp_db', 'digimail_smtp_revoked', 'digimail_smtp_last_failure', 'digimail_smtp_imported', 'digimail_smtp_contacts', 'digimail_smtp_contacts_last', 'digimail_smtp_guard_log', 'digimail_smtp_guard_stats', 'digimail_smtp_guard_seen', 'digimail_smtp_guard_secret', 'digimail_smtp_guard_allow', 'digimail_smtp_limit_hit', 'digimail_smtp_review' ) as $digimail_smtp_option ) { 20 20 delete_option( $digimail_smtp_option ); 21 21 }
Note:
See TracChangeset
for help on using the changeset viewer.