This commit is contained in:
2025-06-22 15:47:32 +03:00
parent ccbb317189
commit b3b86ecd9a
18 changed files with 422 additions and 182 deletions

31
mailer.rb Normal file
View 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