Question 1: How to use the megic link feature without user id?
In the web sdk, the user id is required to send a magic link. Is there a way to use createMagicURLSession
only with the email address of a user?
Question 2: Can I use Functions to send a magic link? I want to use appwrite functions to send a magic link to a user through a custom mail server. Which method of the server sdk to I have to use to generate the magic link?
Kind regards, Marius
- The
userId
in thecreateMagicURLSession
endpoint is something that needs to be passed in, to make sure there is a unique ID attached to the user. You can use theID.unique()
helper that comes with the appwrite sdk, to generate and assign a unique ID on the go. - As far as I know this is not possible. Why don't you set up your mail server in Appwrite's env file, and use it as is?
Thank you for the fast response!
- I want to provide a passwordless login to existing users. The user should just enter his/her email and should be able to receive a login link. Isn't that possible?
- I am using the cloud version and I also want to use custom html in the email. I haved panned to use resend.com as email provider.
No issues π
Okay so I looked at the code, and it seems like the userId
doesn't matter if the email
already exists in your project. So you should be able to do something like this:
const promise = account.createMagicURLSession(ID.unique(), 'abc@example.com');
And the userId
would come into play, only if a user with the specified email
doesn't already exist.
As for your second point, custom email templates aren't a feature yet. You can play around with the docker compose file in a self-hosted instance, but can't really do much in Appwrite Cloud, as SMTP and templates are handled by the Appwrite team.
Let me know if you have any more questions!
This was very helpful. Thank you @safwan!
Recommended threads
- Send Email Verification With REST
I am using REST to create a user on the server side after receiving form data from the client. After the account is successfully created i wanted to send the v...
- Use different email hosts for different ...
Hello, I have 2 projects and i want to be able to set up email templates in the projects. Both projects will have different email host configurations. I see ...
- Get team fail in appwrite function
I try to get team of a user inside appwrite function, but i get this error: `AppwriteException: User (role: guests) missing scope (teams.read)` If i try on cl...