Fixes
This commit is contained in:
31
mailer.rb
Normal file
31
mailer.rb
Normal file
@@ -0,0 +1,31 @@
|
||||
# Mailer module
|
||||
module Mail
|
||||
def send(to, subject, body)
|
||||
from_email = "noreply@infinsweeper.syedm.dev"
|
||||
from_name = "InfinSweeper"
|
||||
to = Array(to).map { |addr| { email_address: { address: addr, name: "" } } }
|
||||
|
||||
payload = {
|
||||
from: {
|
||||
address: from_email,
|
||||
name: from_name,
|
||||
},
|
||||
to: to,
|
||||
subject: subject,
|
||||
htmlbody: body,
|
||||
}
|
||||
|
||||
uri = URI("https://api.zeptomail.com/v1.1/email")
|
||||
req = Net::HTTP::Post.new(uri)
|
||||
req["Authorization"] = "Zoho-enczapikey #{ENV_HASH["ZOHO_PASS"]}"
|
||||
req["Content-Type"] = "application/json"
|
||||
req.body = payload.to_json
|
||||
|
||||
http = Net::HTTP.new(uri.host, uri.port)
|
||||
http.use_ssl = true
|
||||
response = http.request(req)
|
||||
|
||||
return if response.is_a?(Net::HTTPSuccess)
|
||||
Logman.imp "[ZeptoMail ERROR] #{response.body}"
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user