> ## Documentation Index
> Fetch the complete documentation index at: https://docs.portalhq.io/llms.txt
> Use this file to discover all available pages before exploring further.

# sendMagicLink

> Email the user a magic link that signs them in when opened.

## Function Signature

```dart theme={null}
Future<void> sendMagicLink(String email)
```

## Description

A [`PortalAuth`](./portalauth) method. Sends a magic-link email to `email`. It completes once the email is handed off for delivery; the sign-in itself finishes when the user opens the link and your app passes the redirect to [`handleRedirect`](./portalauthhandleredirect).

The address is trimmed and lowercased before it is sent. Every call sends a real email, and sends are rate limited to 10 per address per minute, so never retry automatically; make a resend an explicit user action.

Requires a `magicLink` configuration in [`configure`](./portalauthconfigure).

Available starting from `portal_flutter` 2.0.0.

## Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `email` | `String` | Yes | The user's email address. |

## Returns

**`Future<void>`** - Completes once the email is sent.

## Example

```dart theme={null}
import 'package:portal_flutter/portal_flutter.dart';

Future<void> sendLink(String email) async {
  try {
    await PortalAuth().sendMagicLink(email);
    print('Check your inbox');
  } on PortalException catch (e) {
    if (e.code == 'AUTH_RATE_LIMITED') {
      print('Too many emails sent. Wait a minute before resending.');
    } else {
      print('Could not send the link (${e.code}): ${e.message}');
    }
  }
}
```

## Errors

| Code | Description |
| - | - |
| `AUTH_INVALID_ARGUMENT` | `email` is blank. Thrown before any network call |
| `AUTH_NOT_CONFIGURED` | Called before [`configure`](./portalauthconfigure) |
| `AUTH_MAGIC_LINK_NOT_CONFIGURED` | `configure` was called without `magicLink`. Thrown before any network call |
| `AUTH_RATE_LIMITED` | Too many magic links were sent to this address |
| `AUTH_ACCOUNT_ABSTRACTION_UNAVAILABLE` | `isAccountAbstracted: true` was requested without gas sponsorship enabled. iOS only; Android reports `AUTH_SEND_MAGIC_LINK_ERROR` |
| `AUTH_SEND_MAGIC_LINK_ERROR` | A network or server error |

## Related

* [Email magic link guide](../guide/client-auth#email-magic-link)
* [handleRedirect](./portalauthhandleredirect)
* [Email magic links](../../../resources/authentication/email-magic-links)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.