-
Notifications
You must be signed in to change notification settings - Fork 131
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
Email verification #195
Comments
Hey @Mustimain, I recently asked myself the same question when I started a new project. Have you already found a solution to this or is the question still open? |
still open unfortunately i couldn't find a solution |
@Mustimain i have now sat down to the problem and complete the email verification via a small detour. I created a FirebaseAdmin.FirebaseApp after the registration and created the link based on the email from the user. Afterwards I deleted the FirebaseApp instance. public async Task RegistrationUser(string email, string password, string username)
{
UserCredential = await authViewModel.RegisterUserWithEmail(email, password, username);
User = UserCredential.User;
FirebaseApp.Create(new AppOptions()
{
Credential = GoogleCredential.FromFile(filePath)
});
var link = await FirebaseAuth.DefaultInstance.GenerateEmailVerificationLinkAsync(email);
FirebaseApp.DefaultInstance.Delete();
await SendEmailVerificationAsync(link, email, username);
} Afterwards I created a SmtpClient and sent an email to the user. This worked fine for me. (So you can also design the email according to your own wishes, which was also my wish). Let me know if I could help you a little bit with my detour. |
@domsse thank you for your help solved my problem |
@domsse @Mustimain were you working on a .NET MAUI app? I can't get SmtpClient to work on .NET MAUI. |
Hi @koddek I have been working with a .NET MAUI application. I used normal SmtpClient (using System.Net.Mail) with own credential. What did you do? Do you have a sample code for me where it doesn't work? |
Hi @domsse, thanks for your reply
I created a clean .NET MAUI app. Both the XAML and Blazor versions.
public void SendEmailUsingMicrosoftSmtp()
{
var fromName = "Jon";
var fromEmail = "EMAIL@outlook.com";
var fromPass = "EMAILPASSWORD";
var toName = "Jane";
var toEmail = "JANEEMAIL@outlook.com";
var message = new MimeMessage();
message.From.Add(new MailboxAddress(fromName, fromEmail));
message.To.Add(new MailboxAddress(toName, toEmail));
message.Subject = "Hello from Microsoft SMTP";
var bodyBuilder = new BodyBuilder
{
HtmlBody = "This is an email sent via Microsoft SMTP with SSL on port 587."
};
message.Body = bodyBuilder.ToMessageBody();
using var client = new SmtpClient();
client.Connect("smtp.office365.com", 587, SecureSocketOptions.StartTls);
// client.Connect("smtp.office365.com", 465, SecureSocketOptions.SslOnConnect);
client.Authenticate(fromEmail, fromPass);
client.Send(message);
client.Disconnect(true);
} This code works on Blazor Server, but not on Webassembly. |
How can I send an email for email verification? Please help me
The text was updated successfully, but these errors were encountered: