mirror of https://github.com/docusealco/docuseal
				
				
				
			
			You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							30 lines
						
					
					
						
							912 B
						
					
					
				
			
		
		
	
	
							30 lines
						
					
					
						
							912 B
						
					
					
				| # frozen_string_literal: true
 | |
| 
 | |
| module ActionMailerConfigsInterceptor
 | |
|   module_function
 | |
| 
 | |
|   def delivering_email(message)
 | |
|     if Rails.env.production? && Rails.application.config.action_mailer.delivery_method
 | |
|       message.from = ENV.fetch('SMTP_FROM')
 | |
| 
 | |
|       return message
 | |
|     end
 | |
| 
 | |
|     email_configs = EncryptedConfig.find_by(key: EncryptedConfig::EMAIL_SMTP_KEY)
 | |
| 
 | |
|     if email_configs
 | |
|       message.delivery_method(:smtp, user_name: email_configs.value['username'],
 | |
|                                      password: email_configs.value['password'],
 | |
|                                      address: email_configs.value['host'],
 | |
|                                      port: email_configs.value['port'],
 | |
|                                      tls: email_configs.value['port'].to_s == '465')
 | |
| 
 | |
|       message.from = email_configs.value['from_email']
 | |
|     else
 | |
|       message.delivery_method(:test)
 | |
|     end
 | |
| 
 | |
|     message
 | |
|   end
 | |
| end
 |