multiple SMTP provider settings #29496
Replies: 2 comments 1 reply
-
Supabase natively supports only one SMTP provider, but you can build custom logic in your backend for multiple SMTP providers and failover functionality. |
Beta Was this translation helpful? Give feedback.
-
3. Integrate the Custom Email Logic with SupabaseYou can use the Supabase client to trigger your custom email-sending function, either after a user action or based on some event (e.g., after sign-up, after password reset request). For example, you can set up a Supabase function or webhook that listens for certain events (like new user signups) and then triggers your email-sending logic: const { createClient } = require('@supabase/supabase-js');
// Supabase client setup
const supabase = createClient(process.env.SUPABASE_URL, process.env.SUPABASE_ANON_KEY);
// Example of sending an email after user signup
async function onUserSignup(userId) {
const { data, error } = await supabase
.from('users')
.select('email')
.eq('id', userId);
if (error) {
console.error('Error fetching user email: ', error);
return;
}
const userEmail = data[0].email;
// Send a welcome email using your custom SMTP logic
sendEmail({
from: '"Your Service" <[email protected]>',
to: userEmail,
subject: 'Welcome to Our Service!',
text: 'Thank you for signing up!',
});
}
// Trigger this function on a new signup event
supabase.auth.onAuthStateChange((event, session) => {
if (event === 'SIGNED_IN') {
onUserSignup(session.user.id);
}
}); |
Beta Was this translation helpful? Give feedback.
-
the current SMTP setting only allows one provider, is it possible to have multiple or one more as backup that does nothing.
Hence if the SMTP service is down, we are able to one click swapping to the backup, hence the default (the one is down) turns into the backup in this case until it recovers.
Beta Was this translation helpful? Give feedback.
All reactions