From 72c99a976c21f96ee9e78530074c37fd9d7e0a73 Mon Sep 17 00:00:00 2001 From: Amitai Burstein Date: Mon, 15 Jan 2024 14:01:00 +0200 Subject: [PATCH 1/2] Show example how to send a link from Mail --- Guide/mail.markdown | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/Guide/mail.markdown b/Guide/mail.markdown index e9fef71ad..e85e9f333 100644 --- a/Guide/mail.markdown +++ b/Guide/mail.markdown @@ -76,7 +76,7 @@ replyTo ConfirmationMail { .. } = Just Address { addessName = Just "Support", ad ### Email Content -Last we need to change the email text a little bit. The mail supports HSX so this is similar to writing an IHP view: +Lastly, we need to change the email text a little bit. The mail supports HSX, so this is similar to writing an IHP view: ```haskell html ConfirmationMail { .. } = [hsx| @@ -85,6 +85,31 @@ Last we need to change the email text a little bit. The mail supports HSX so thi |] ``` +We can also include links. It's likely that you'd have a function to return the correct link; for example, after posting a comment, you will send notifications. +Inside `Mail` we don't use `ControllerContext`, so if we have such a function we would need a different type signature. So it could work both from inside `Mail` and a `Controller`. +The reason we don't have `ControllerContext`, is because a `Mail` can be sent via IHP scripts. + +```hasekll +# Application/Helper/Controller.hs + +redirectExample :: forall context. (?context :: context, ConfigProvider context) => Text +redirectExample = urlTo LmNamesAction +``` + +Then we can use it in the `Mail`. + +```haskell + html ConfirmationMail { .. } = [hsx| + Hey {user.name},
+

+ Thanks for signing up! Please confirm your account by following this link: ... +

+ +

+ Click here to view all Posts + |] +``` + ## Sending Mails From inside a controller or script, an email can be sent by using [`sendMail`](https://ihp.digitallyinduced.com/api-docs/IHP-Mail.html#v:sendMail): From fcb4a10ee1c84ead8cab38e35f072007baa8c01a Mon Sep 17 00:00:00 2001 From: Amitai Burstein Date: Mon, 15 Jan 2024 14:01:40 +0200 Subject: [PATCH 2/2] Update Guide/mail.markdown --- Guide/mail.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/Guide/mail.markdown b/Guide/mail.markdown index e85e9f333..b86344ec6 100644 --- a/Guide/mail.markdown +++ b/Guide/mail.markdown @@ -107,6 +107,7 @@ Then we can use it in the `Mail`.

Click here to view all Posts +

|] ```