Files
2026-09-24 18:49:34 +01:00

34 lines
845 B
Ruby

# Mailer module
module Mail
def send(to, subject, body)
from_email = "infinsweeper@domain.com"
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["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}"
raise "Email failed."
end
end