rails catch mail error
# Step 1: Wrap the mail sending code in a begin-rescue block to catch exceptions
begin
# Your mail sending code here
# Example:
UserMailer.welcome_email(user).deliver_now
rescue => e
# Step 2: Handle the exception and log the error
Rails.logger.error("Error sending email: #{e.message}")
# Optional: You can re-raise the exception if needed
# raise e
end