adjust from email
This commit is contained in:
@@ -49,6 +49,9 @@ class User < ApplicationRecord
|
|||||||
|
|
||||||
EMAIL_REGEXP = /[^@;,<>\s]+@[^@;,<>\s]+/
|
EMAIL_REGEXP = /[^@;,<>\s]+@[^@;,<>\s]+/
|
||||||
|
|
||||||
|
FULL_EMAIL_REGEXP =
|
||||||
|
/\A[a-z0-9][\.']?(?:(?:[a-z0-9_-]+[\.\+'])*[a-z0-9_-]+)*@(?:[a-z0-9]+[\.-])*[a-z0-9]+\.[a-z]{2,}\z/i
|
||||||
|
|
||||||
has_one_attached :signature
|
has_one_attached :signature
|
||||||
has_one_attached :initials
|
has_one_attached :initials
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,11 @@ module ActionMailerConfigsInterceptor
|
|||||||
if Rails.env.production? && Rails.application.config.action_mailer.delivery_method
|
if Rails.env.production? && Rails.application.config.action_mailer.delivery_method
|
||||||
from = ENV.fetch('SMTP_FROM').to_s.split(',').sample
|
from = ENV.fetch('SMTP_FROM').to_s.split(',').sample
|
||||||
|
|
||||||
message.from = from
|
if from.match?(User::FULL_EMAIL_REGEXP)
|
||||||
|
message[:from] = message[:from].to_s.sub(User::EMAIL_REGEXP, from)
|
||||||
|
else
|
||||||
|
message.from = from
|
||||||
|
end
|
||||||
|
|
||||||
if from == 'DocuSeal <info@docuseal.com>'
|
if from == 'DocuSeal <info@docuseal.com>'
|
||||||
message.body.instance_variable_set(
|
message.body.instance_variable_set(
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
module Params
|
module Params
|
||||||
class BaseValidator
|
class BaseValidator
|
||||||
EMAIL_REGEXP = /\A[a-z0-9][\.']?(?:(?:[a-z0-9_-]+[\.\+'])*[a-z0-9_-]+)*@(?:[a-z0-9]+[\.-])*[a-z0-9]+\.[a-z]{2,}\z/i
|
EMAIL_REGEXP = User::FULL_EMAIL_REGEXP
|
||||||
|
|
||||||
InvalidParameterError = Class.new(StandardError)
|
InvalidParameterError = Class.new(StandardError)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user