Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show example how to send a link from Mail #1894

Merged
merged 2 commits into from
Jan 16, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion Guide/mail.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand All @@ -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}, <br/>
<p>
Thanks for signing up! Please confirm your account by following this link: ...
</p>

<p>
<a href={redirectExample}>Click here to view all Posts</a>
amitaibu marked this conversation as resolved.
Show resolved Hide resolved
|]
```

## 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):
Expand Down
Loading