tempmail_sdk 1.3.6 → 1.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce354c565d41b72b8747b7c8e4d6fe460cb79d9ce35f0ab9d580d85707862848
4
- data.tar.gz: 271328d1244cc3f509595d47ac63f82c91b9a24b0c3f6ff0c7b83b41ba33a76a
3
+ metadata.gz: 230d2969ea21971d1b54deb964846e8eb8ba4d4e1f9c39a63093d39fc6490578
4
+ data.tar.gz: f952d618d78cb5dc5be4429eea1b93b8ff67dbee6b7ab9691caee959e1ab56d8
5
5
  SHA512:
6
- metadata.gz: 8f1efda85071b81ebff4e2c3a1b7f6154902a3cbbbcb179d0405f834df30ff7226b18426eeeac47900546c954bc5469ce4a62169ff34ada3d3e038bba2a43734
7
- data.tar.gz: 801518603c4bbad61769e106b942a8a15996993d593bc6c075ab7a1aaebc85ae6372cb57e3915103a740742ad8eaff3aacd6500b942cbd3f964918040523532f
6
+ metadata.gz: '09f6f31c4e06867c0baef660f72ad927656139bc042d90ba869e64fe44fbee91c97e285b7216abe632e2e503b4243527be90c33b25ef898715e8040ce3fb02de'
7
+ data.tar.gz: 62cf053c6265606a27b2c24990dd6199bb42716bbed1ff17448fb23422d1b17197ddce704d46d903b10f5ed75b3bd525ea58321ec112376785edb592c3ac26c7
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  #
3
- # 渠道标识常量模块(290 个),常量值即渠道 slug。
3
+ # 渠道标识常量模块(316 个),常量值即渠道 slug。
4
4
  # 由 .channel_meta.json 生成,供用户以常量方式引用渠道,避免手写字符串出错。
5
5
  #
6
6
  module TempmailSdk
@@ -310,5 +310,17 @@ module TempmailSdk
310
310
  NICEGROUND_SHOP = "niceground-shop"
311
311
  GLASSWHITEHUB_COM = "glasswhitehub-com"
312
312
  HUBAICLASS_ORG = "hubaiclass-org"
313
+ DUMMYINBOX = "dummyinbox"
314
+ PLAINLYKIT = "plainlykit"
315
+ MAILBOXTEMP = "mailboxtemp"
316
+ NEXTMAIL = "nextmail"
317
+ TSUKAISUTEMAIL = "tsukaisutemail"
318
+ TEMPMAILIFY = "tempmailify"
319
+ GRABMAIL = "grabmail"
320
+ TEMPMAILS_CC = "tempmails-cc"
321
+ GENIUSGSM = "geniusgsm"
322
+ TEMP_TF = "temp-tf"
323
+ ANOTHERKEVIN_COM = "anotherkevin-com"
324
+ ALVIONGROUP_CLOUD = "alviongroup-cloud"
313
325
  end
314
326
  end
@@ -4,7 +4,7 @@
4
4
  # 每项为 [slug, name, website],注册表按此顺序枚举,顺序为硬约束。
5
5
  #
6
6
  module TempmailSdk
7
- # 290 个渠道的有序元数据
7
+ # 316 个渠道的有序元数据
8
8
  CHANNEL_DATA = [
9
9
  ["tempmail", "TempMail", "tempmail.ing"],
10
10
  ["tempmail-cn", "TempMail CN", "tempmail.cn"],
@@ -310,5 +310,17 @@ module TempmailSdk
310
310
  ["niceground-shop", "niceground.shop", "duckmail.sbs"],
311
311
  ["glasswhitehub-com", "glasswhitehub.com", "duckmail.sbs"],
312
312
  ["hubaiclass-org", "hubaiclass.org", "duckmail.sbs"],
313
+ ["dummyinbox", "DummyInbox", "dummyinbox.com"],
314
+ ["plainlykit", "PlainlyKit", "plainlykit.com"],
315
+ ["mailboxtemp", "MailboxTemp", "mailboxtemp.com"],
316
+ ["nextmail", "Nextmail", "nextmail.sh"],
317
+ ["tsukaisutemail", "Tsukaisute Mail", "tsukaisutemail.com"],
318
+ ["tempmailify", "Tempmailify", "tempmailify.com"],
319
+ ["grabmail", "GrabMail", "grabmail.io"],
320
+ ["tempmails-cc", "tempmails.cc", "tempmails.cc"],
321
+ ["geniusgsm", "GeniusGSM", "tempmail.geniusgsm.com"],
322
+ ["temp-tf", "temp.tf", "temp.tf"],
323
+ ["anotherkevin-com", "anotherkevin.com", "tempmails.cc"],
324
+ ["alviongroup-cloud", "alviongroup.cloud", "tempmails.cc"],
313
325
  ].freeze
314
326
  end
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "cgi"
4
+
5
+ module TempmailSdk
6
+ module Providers
7
+ # DummyInbox 渠道 — https://dummyinbox.com
8
+ # 无需密钥;创建随机地址后,地址本身即读取凭据。
9
+ module DummyInbox
10
+ CHANNEL = "dummyinbox"
11
+ BASE_URL = "https://dummyinbox.com/api/v1"
12
+ HEADERS = { "Accept" => "application/json" }.freeze
13
+
14
+ module_function
15
+
16
+ def path_address(address)
17
+ CGI.escape(address.strip).gsub("%40", "@")
18
+ end
19
+
20
+ def fetch_json(url)
21
+ resp = Http.get(url, headers: HEADERS, timeout: 20)
22
+ resp.raise_for_status
23
+ resp.json
24
+ end
25
+
26
+ # 创建 DummyInbox 临时邮箱
27
+ # @return [EmailInfo]
28
+ def generate_email
29
+ resp = Http.post("#{BASE_URL}/inboxes", headers: HEADERS, timeout: 20)
30
+ resp.raise_for_status
31
+ address = resp.json["address"].to_s.strip
32
+ raise "dummyinbox: 创建响应缺少地址" if address.empty?
33
+
34
+ EmailInfo.new(channel: CHANNEL, email: address)
35
+ end
36
+
37
+ # @param email [String]
38
+ # @return [Array<Email>]
39
+ def get_emails(email)
40
+ address = email.to_s.strip
41
+ raise "dummyinbox: 邮箱地址为空" if address.empty?
42
+
43
+ path = path_address(address)
44
+ data = fetch_json("#{BASE_URL}/inboxes/#{path}/messages?limit=50")
45
+ (data["messages"] || []).filter_map do |item|
46
+ message_id = item["id"].to_s.strip
47
+ next if message_id.empty?
48
+
49
+ begin
50
+ detail = fetch_json("#{BASE_URL}/inboxes/#{path}/messages/#{CGI.escape(message_id)}")
51
+ message = detail["message"]
52
+ if message.is_a?(Hash)
53
+ to = message["to"].is_a?(Array) ? message["to"].first : message["to"]
54
+ next Normalize.normalize_email({
55
+ "id" => message["id"], "from" => message["from"],
56
+ "to" => to || address, "subject" => message["subject"],
57
+ "text" => message["text"], "html" => message["html"],
58
+ "date" => message["receivedAt"],
59
+ "attachments" => message["attachments"]
60
+ }, address)
61
+ end
62
+ rescue StandardError
63
+ # 详情失败时退回摘要
64
+ end
65
+
66
+ Normalize.normalize_email({
67
+ "id" => message_id, "from" => item["from"], "to" => address,
68
+ "subject" => item["subject"], "text" => item["snippet"],
69
+ "date" => item["receivedAt"]
70
+ }, address)
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "cgi"
4
+
5
+ module TempmailSdk
6
+ module Providers
7
+ # GeniusGSM 渠道 — https://tempmail.geniusgsm.com
8
+ # 创建收件箱返回内部 ID;收件箱列表响应已包含 body_text / body_html。
9
+ module GeniusGSM
10
+ CHANNEL = "geniusgsm"
11
+ BASE_URL = "https://tempmail.geniusgsm.com/api"
12
+ HEADERS = { "Accept" => "application/json", "Content-Type" => "application/json" }.freeze
13
+
14
+ module_function
15
+
16
+ def rows(data)
17
+ return data if data.is_a?(Array)
18
+ return data["results"] if data.is_a?(Hash) && data["results"].is_a?(Array)
19
+
20
+ []
21
+ end
22
+
23
+ def from_value(raw)
24
+ name = raw["from_name"].to_s
25
+ addr = raw["from_email"].to_s
26
+ name.empty? || addr.empty? ? addr : "#{name} <#{addr}>"
27
+ end
28
+
29
+ # 选择激活域名并创建收件箱
30
+ # @return [EmailInfo]
31
+ def generate_email
32
+ domains_resp = Http.get("#{BASE_URL}/domains/", headers: HEADERS, timeout: 20)
33
+ domains_resp.raise_for_status
34
+ active = rows(domains_resp.json).find { |item| item["is_active"] }
35
+ raise "geniusgsm: 无可用激活域名" unless active
36
+
37
+ resp = Http.post("#{BASE_URL}/inboxes/create_inbox/",
38
+ headers: HEADERS, json: { domain_id: active["id"], ttl: 3600 }, timeout: 20)
39
+ resp.raise_for_status
40
+ data = resp.json
41
+ inbox_id = data["id"].to_s.strip
42
+ address = data["email"].to_s.strip
43
+ raise "geniusgsm: 创建响应不完整" if inbox_id.empty? || address.empty?
44
+
45
+ EmailInfo.new(channel: CHANNEL, email: address, token: inbox_id,
46
+ created_at: data["created_at"], expires_at: data["expires_at"])
47
+ end
48
+
49
+ # @param email [String]
50
+ # @param token [String] 收件箱 ID
51
+ # @return [Array<Email>]
52
+ def get_emails(email, token)
53
+ inbox_id = token.to_s.strip
54
+ raise "geniusgsm: 收件箱 ID 为空" if inbox_id.empty?
55
+
56
+ resp = Http.get("#{BASE_URL}/inboxes/#{CGI.escape(inbox_id)}/emails/",
57
+ headers: HEADERS, timeout: 20)
58
+ resp.raise_for_status
59
+ rows(resp.json).map do |item|
60
+ Normalize.normalize_email({
61
+ "id" => item["id"], "from" => from_value(item),
62
+ "to" => item["inbox_email"] || email,
63
+ "subject" => item["subject"],
64
+ "text" => item["body_text"], "html" => item["body_html"],
65
+ "date" => item["received_at"], "read" => item["is_read"],
66
+ "attachments" => item["attachments"]
67
+ }, email)
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "cgi"
4
+
5
+ module TempmailSdk
6
+ module Providers
7
+ # GrabMail 渠道 — https://grabmail.io
8
+ # 地址即邮箱:首封邮件到达时自动存在,无需创建。
9
+ module Grabmail
10
+ CHANNEL = "grabmail"
11
+ BASE_URL = "https://grabmail.io/api/v1"
12
+ DOMAIN = "grabmail.io"
13
+ HEADERS = { "Accept" => "application/json" }.freeze
14
+
15
+ module_function
16
+
17
+ def random_local
18
+ chars = ("a".."z").to_a + ("0".."9").to_a
19
+ "sdk" + Array.new(16) { chars.sample }.join
20
+ end
21
+
22
+ def get_json(url)
23
+ resp = Http.get(url, headers: HEADERS, timeout: 20)
24
+ resp.raise_for_status
25
+ resp.json
26
+ end
27
+
28
+ def from_value(raw)
29
+ name = raw["from_name"].to_s
30
+ addr = raw["from"].to_s
31
+ name.empty? ? addr : "#{name} <#{addr}>"
32
+ end
33
+
34
+ # 生成 GrabMail 地址(无需请求服务端)
35
+ # @return [EmailInfo]
36
+ def generate_email
37
+ EmailInfo.new(channel: CHANNEL, email: "#{random_local}@#{DOMAIN}")
38
+ end
39
+
40
+ # @param email [String]
41
+ # @return [Array<Email>]
42
+ def get_emails(email)
43
+ address = email.to_s.strip
44
+ raise "grabmail: 邮箱地址为空" if address.empty?
45
+
46
+ data = get_json("#{BASE_URL}/mailbox?address=#{CGI.escape(address).gsub('%40', '@')}")
47
+ (data["messages"] || []).filter_map do |item|
48
+ message_id = item["id"].to_s.strip
49
+ next if message_id.empty?
50
+
51
+ begin
52
+ detail = get_json("#{BASE_URL}/message/#{CGI.escape(message_id)}" \
53
+ "?mailbox=#{CGI.escape(address).gsub('%40', '@')}")
54
+ next Normalize.normalize_email({
55
+ "id" => detail["id"] || message_id,
56
+ "from" => from_value(detail), "to" => address,
57
+ "subject" => detail["subject"],
58
+ "text" => detail["text"], "html" => detail["html"],
59
+ "date" => detail["date"], "seen" => detail["seen"],
60
+ "attachments" => detail["attachments"]
61
+ }, address)
62
+ rescue StandardError
63
+ # 详情失败时退回摘要
64
+ end
65
+
66
+ Normalize.normalize_email({
67
+ "id" => message_id, "from" => from_value(item),
68
+ "to" => address, "subject" => item["subject"],
69
+ "text" => item["preview"], "date" => item["date"],
70
+ "seen" => item["seen"]
71
+ }, address)
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "cgi"
4
+
5
+ module TempmailSdk
6
+ module Providers
7
+ # MailboxTemp 渠道 — https://mailboxtemp.com
8
+ # 无需密钥;创建免费邮箱后,地址即读取凭据。
9
+ module MailboxTemp
10
+ CHANNEL = "mailboxtemp"
11
+ BASE_URL = "https://mailboxtemp.com"
12
+ HEADERS = { "Accept" => "application/json" }.freeze
13
+
14
+ module_function
15
+
16
+ def fetch_json(url)
17
+ resp = Http.get(url, headers: HEADERS, timeout: 20)
18
+ data = resp.json
19
+ raise "mailboxtemp: HTTP #{resp.status_code}" if resp.status_code >= 400 || data["ok"] == false
20
+
21
+ data
22
+ end
23
+
24
+ # 创建 MailboxTemp 临时邮箱
25
+ # @return [EmailInfo]
26
+ def generate_email
27
+ resp = Http.post("#{BASE_URL}/api/inbox/generate", headers: HEADERS, timeout: 20)
28
+ data = resp.json
29
+ address = data["address"].to_s.strip
30
+ if resp.status_code >= 400 || data["ok"] == false || address.empty?
31
+ raise "mailboxtemp: 创建邮箱 HTTP #{resp.status_code}"
32
+ end
33
+
34
+ EmailInfo.new(channel: CHANNEL, email: address, expires_at: data["expires"])
35
+ end
36
+
37
+ # @param email [String]
38
+ # @return [Array<Email>]
39
+ def get_emails(email)
40
+ address = email.to_s.strip
41
+ raise "mailboxtemp: 邮箱地址为空" if address.empty?
42
+
43
+ path = CGI.escape(address)
44
+ data = fetch_json("#{BASE_URL}/api/inbox/#{path}/emails")
45
+ (data["emails"] || []).filter_map do |item|
46
+ message_id = item["id"].to_s.strip
47
+ next if message_id.empty?
48
+
49
+ begin
50
+ detail = fetch_json("#{BASE_URL}/api/email/#{path}/#{CGI.escape(message_id)}")
51
+ message = detail["email"]
52
+ if message.is_a?(Hash)
53
+ next Normalize.normalize_email({
54
+ "id" => message["id"], "from" => message["from_address"],
55
+ "to" => address, "subject" => message["subject"],
56
+ "text" => message["body_text"], "html" => message["body_html"],
57
+ "date" => message["received_at"], "read" => message["read"],
58
+ "attachments" => detail["attachments"]
59
+ }, address)
60
+ end
61
+ rescue StandardError
62
+ # 详情失败时退回摘要
63
+ end
64
+
65
+ Normalize.normalize_email({
66
+ "id" => message_id, "from" => item["from_address"], "to" => address,
67
+ "subject" => item["subject"], "date" => item["received_at"],
68
+ "read" => item["read"]
69
+ }, address)
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,90 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "cgi"
4
+
5
+ module TempmailSdk
6
+ module Providers
7
+ # Nextmail 渠道 — https://nextmail.sh
8
+ # 创建收件箱返回内部令牌;内部令牌格式为 “收件箱ID|读取令牌”。
9
+ # 详情正文位于 message.decodedBody(HTML)。
10
+ module Nextmail
11
+ CHANNEL = "nextmail"
12
+ BASE_URL = "https://api.nextmail.sh"
13
+
14
+ module_function
15
+
16
+ def split_token(token)
17
+ box_id, bearer = token.to_s.strip.split("|", 2)
18
+ raise "nextmail: 内部令牌格式错误" if box_id.to_s.empty? || bearer.to_s.empty?
19
+
20
+ [box_id, bearer]
21
+ end
22
+
23
+ def fetch_json(url, bearer)
24
+ resp = Http.get(url, headers: { "Accept" => "application/json",
25
+ "Authorization" => "Bearer #{bearer}" }, timeout: 20)
26
+ resp.raise_for_status
27
+ resp.json
28
+ end
29
+
30
+ def from_email(value)
31
+ value.is_a?(Hash) ? value["email"].to_s : value.to_s
32
+ end
33
+
34
+ # 租用 Nextmail 临时收件箱
35
+ # @return [EmailInfo]
36
+ def generate_email
37
+ resp = Http.post("#{BASE_URL}/temp-mail/inboxes",
38
+ headers: { "Accept" => "application/json",
39
+ "Content-Type" => "application/json" },
40
+ json: {}, timeout: 20)
41
+ resp.raise_for_status
42
+ data = resp.json
43
+ address = data["address"].to_s.strip
44
+ box_id = data["id"].to_s.strip
45
+ token = data["token"].to_s.strip
46
+ if address.empty? || box_id.empty? || token.empty?
47
+ raise "nextmail: 创建响应不完整"
48
+ end
49
+
50
+ EmailInfo.new(channel: CHANNEL, email: address, token: "#{box_id}|#{token}",
51
+ created_at: data["createdAt"], expires_at: data["expiresAt"])
52
+ end
53
+
54
+ # @param email [String]
55
+ # @param token [String]
56
+ # @return [Array<Email>]
57
+ def get_emails(email, token)
58
+ box_id, bearer = split_token(token)
59
+ base = "#{BASE_URL}/temp-mail/inboxes/#{CGI.escape(box_id)}/messages"
60
+ data = fetch_json("#{base}?limit=50", bearer)
61
+ (data["data"] || []).filter_map do |item|
62
+ message_id = item["id"].to_s.strip
63
+ next if message_id.empty?
64
+
65
+ begin
66
+ detail = fetch_json("#{base}/#{CGI.escape(message_id)}", bearer)
67
+ message = detail["message"].is_a?(Hash) ? detail["message"] : {}
68
+ next Normalize.normalize_email({
69
+ "id" => detail["id"] || message_id,
70
+ "from" => from_email(detail["from"]),
71
+ "to" => detail["to"] || email,
72
+ "subject" => detail["subject"],
73
+ "html" => message["decodedBody"],
74
+ "date" => detail["receivedAt"], "seen" => detail["seen"]
75
+ }, email)
76
+ rescue StandardError
77
+ # 详情失败时退回摘要
78
+ end
79
+
80
+ Normalize.normalize_email({
81
+ "id" => message_id, "from" => from_email(item["from"]),
82
+ "to" => item["to"] || email, "subject" => item["subject"],
83
+ "text" => item["snippet"], "date" => item["receivedAt"],
84
+ "seen" => item["seen"]
85
+ }, email)
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "cgi"
4
+
5
+ module TempmailSdk
6
+ module Providers
7
+ # PlainlyKit 渠道 — https://plainlykit.com
8
+ # 创建邮箱返回内部令牌;内部令牌格式为 “邮箱ID|读取令牌”。
9
+ module PlainlyKit
10
+ CHANNEL = "plainlykit"
11
+ BASE_URL = "https://plainlykit.com/tools/temporary-email/api"
12
+
13
+ module_function
14
+
15
+ def split_token(token)
16
+ box_id, bearer = token.to_s.strip.split("|", 2)
17
+ raise "plainlykit: 内部令牌格式错误" if box_id.to_s.empty? || bearer.to_s.empty?
18
+
19
+ [box_id, bearer]
20
+ end
21
+
22
+ def fetch_json(url, bearer)
23
+ resp = Http.get(url, headers: { "Accept" => "application/json",
24
+ "Authorization" => "Bearer #{bearer}" }, timeout: 20)
25
+ resp.raise_for_status
26
+ resp.json
27
+ end
28
+
29
+ # 创建 PlainlyKit 临时邮箱
30
+ # @return [EmailInfo]
31
+ def generate_email
32
+ resp = Http.post("#{BASE_URL}/mailboxes",
33
+ headers: { "Accept" => "application/json",
34
+ "Content-Type" => "application/json" },
35
+ json: {}, timeout: 20)
36
+ resp.raise_for_status
37
+ data = resp.json
38
+ address = data["address"].to_s.strip
39
+ box_id = data["id"].to_s.strip
40
+ token = data["token"].to_s.strip
41
+ if address.empty? || box_id.empty? || token.empty?
42
+ raise "plainlykit: 创建响应不完整"
43
+ end
44
+
45
+ EmailInfo.new(channel: CHANNEL, email: address, token: "#{box_id}|#{token}",
46
+ created_at: data["createdAt"], expires_at: data["expiresAt"])
47
+ end
48
+
49
+ # @param email [String]
50
+ # @param token [String]
51
+ # @return [Array<Email>]
52
+ def get_emails(email, token)
53
+ box_id, bearer = split_token(token)
54
+ base = "#{BASE_URL}/mailboxes/#{CGI.escape(box_id)}/messages"
55
+ data = fetch_json(base, bearer)
56
+ (data["messages"] || []).filter_map do |item|
57
+ message_id = item["id"].to_s.strip
58
+ next if message_id.empty?
59
+
60
+ begin
61
+ detail = fetch_json("#{base}/#{CGI.escape(message_id)}", bearer)
62
+ raw = detail["message"].is_a?(Hash) ? detail["message"] : detail
63
+ from = raw["sender"].to_s.empty? ? item["sender"] : raw["sender"]
64
+ subject = raw["subject"].to_s.empty? ? item["subject"] : raw["subject"]
65
+ next Normalize.normalize_email({
66
+ "id" => raw["id"] || message_id, "from" => from,
67
+ "to" => email, "subject" => subject,
68
+ "text" => raw["text"], "html" => raw["html"],
69
+ "date" => raw["receivedAt"]
70
+ }, email)
71
+ rescue StandardError
72
+ # 详情失败时退回摘要
73
+ end
74
+
75
+ Normalize.normalize_email({
76
+ "id" => message_id, "from" => item["sender"], "to" => email,
77
+ "subject" => item["subject"], "text" => item["preview"],
78
+ "date" => item["receivedAt"]
79
+ }, email)
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "cgi"
4
+
5
+ module TempmailSdk
6
+ module Providers
7
+ # temp.tf 渠道 — https://temp.tf
8
+ # 创建返回一次性地址;收件列表响应按 bodyContentType 归位正文。
9
+ module TempTf
10
+ CHANNEL = "temp-tf"
11
+ BASE_URL = "https://temp.tf/api"
12
+ HEADERS = { "Accept" => "application/json", "Content-Type" => "application/json" }.freeze
13
+
14
+ module_function
15
+
16
+ # 获取一个一次性地址
17
+ # @return [EmailInfo]
18
+ def generate_email
19
+ resp = Http.get("#{BASE_URL}/account?plus=1", headers: HEADERS, timeout: 20)
20
+ resp.raise_for_status
21
+ address = resp.json["email"].to_s.strip
22
+ raise "temp-tf: 创建响应缺少地址" if address.empty?
23
+
24
+ EmailInfo.new(channel: CHANNEL, email: address)
25
+ end
26
+
27
+ # @param email [String]
28
+ # @return [Array<Email>]
29
+ def get_emails(email)
30
+ address = email.to_s.strip
31
+ raise "temp-tf: 邮箱地址为空" if address.empty?
32
+
33
+ resp = Http.post("#{BASE_URL}/check", headers: HEADERS, json: { email: address }, timeout: 20)
34
+ resp.raise_for_status
35
+ (resp.json["data"] || []).map do |item|
36
+ is_text = item["bodyContentType"].to_s.downcase == "text"
37
+ body = item["body"].to_s
38
+ Normalize.normalize_email({
39
+ "id" => item["id"], "from" => item["from"], "to" => address,
40
+ "subject" => item["subject"],
41
+ "text" => is_text ? body : "", "html" => is_text ? "" : body,
42
+ "date" => item["date"], "attachments" => item["attachments"]
43
+ }, address)
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "cgi"
4
+
5
+ module TempmailSdk
6
+ module Providers
7
+ # Tempmailify 渠道 — https://tempmailify.com
8
+ # 创建邮箱返回收件箱专属 Bearer 令牌;详情提供完整 text/html。
9
+ module Tempmailify
10
+ CHANNEL = "tempmailify"
11
+ BASE_URL = "https://tempmailify.com"
12
+
13
+ module_function
14
+
15
+ def from_address(value)
16
+ return value["address"].to_s if value.is_a?(Hash)
17
+
18
+ value.to_s
19
+ end
20
+
21
+ def fetch_json(url, bearer)
22
+ resp = Http.get(url, headers: { "Accept" => "application/json",
23
+ "Authorization" => "Bearer #{bearer}" }, timeout: 20)
24
+ resp.raise_for_status
25
+ resp.json
26
+ end
27
+
28
+ # 创建 Tempmailify 临时邮箱
29
+ # @return [EmailInfo]
30
+ def generate_email
31
+ resp = Http.post("#{BASE_URL}/api/inbox",
32
+ headers: { "Accept" => "application/json",
33
+ "Content-Type" => "application/json" },
34
+ json: {}, timeout: 20)
35
+ resp.raise_for_status
36
+ data = resp.json
37
+ address = data["address"].to_s.strip
38
+ token = data["token"].to_s.strip
39
+ raise "tempmailify: 创建响应不完整" if address.empty? || token.empty?
40
+
41
+ EmailInfo.new(channel: CHANNEL, email: address, token: token,
42
+ created_at: data["createdAt"], expires_at: data["expiresAt"])
43
+ end
44
+
45
+ # @param email [String]
46
+ # @param token [String]
47
+ # @return [Array<Email>]
48
+ def get_emails(email, token)
49
+ address = email.to_s.strip
50
+ bearer = token.to_s.strip
51
+ raise "tempmailify: 邮箱地址或令牌为空" if address.empty? || bearer.empty?
52
+
53
+ base = "#{BASE_URL}/api/inbox/#{CGI.escape(address).gsub('%40', '@')}"
54
+ data = fetch_json(base, bearer)
55
+ (data["messages"] || []).filter_map do |item|
56
+ message_id = item["id"].to_s.strip
57
+ next if message_id.empty?
58
+
59
+ begin
60
+ detail = fetch_json("#{base}/messages/#{CGI.escape(message_id)}", bearer)
61
+ next Normalize.normalize_email({
62
+ "id" => detail["id"] || message_id,
63
+ "from" => from_address(detail["from"]),
64
+ "to" => detail["to"] || address,
65
+ "subject" => detail["subject"] || item["subject"],
66
+ "text" => detail["text"], "html" => detail["html"],
67
+ "date" => detail["receivedAt"] || item["receivedAt"],
68
+ "seen" => detail["seen"],
69
+ "attachments" => detail["attachments"]
70
+ }, address)
71
+ rescue StandardError
72
+ # 详情失败时退回摘要
73
+ end
74
+
75
+ Normalize.normalize_email({
76
+ "id" => message_id, "from" => from_address(item["from"]),
77
+ "to" => address, "subject" => item["subject"],
78
+ "text" => item["preview"], "date" => item["receivedAt"],
79
+ "seen" => item["seen"]
80
+ }, address)
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,91 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "cgi"
4
+
5
+ module TempmailSdk
6
+ module Providers
7
+ # tempmails.cc 渠道 — https://tempmails.cc
8
+ # 地址即邮箱:在公开免费域名上生成地址,无需注册。
9
+ # 详情正文位于 textBody / htmlBody。
10
+ module TempmailsCc
11
+ CHANNEL = "tempmails-cc"
12
+ BASE_URL = "https://tempmails.cc"
13
+ HEADERS = { "Accept" => "application/json" }.freeze
14
+
15
+ module_function
16
+
17
+ def random_local
18
+ chars = ("a".."z").to_a + ("0".."9").to_a
19
+ Array.new(16) { chars.sample }.join
20
+ end
21
+
22
+ def get_json(url)
23
+ resp = Http.get(url, headers: HEADERS, timeout: 20)
24
+ resp.raise_for_status
25
+ resp.json
26
+ end
27
+
28
+ def pick_domain
29
+ data = get_json("#{BASE_URL}/api/domains")
30
+ domain = (data["domainInfo"] || []).filter_map do |item|
31
+ d = item["domain"].to_s.strip
32
+ d unless d.empty?
33
+ end.first
34
+ raise "tempmails-cc: 无可用公开域名" unless domain
35
+
36
+ domain
37
+ end
38
+
39
+ # 在公开免费域名上生成地址
40
+ # @return [EmailInfo]
41
+ def generate_email
42
+ EmailInfo.new(channel: CHANNEL, email: "#{random_local}@#{pick_domain}")
43
+ end
44
+
45
+ # 跳过选域,在指定固定域名上生成地址
46
+ # @param domain [String]
47
+ # @param channel [String]
48
+ # @return [EmailInfo]
49
+ def generate_email_at_domain(domain, channel = CHANNEL)
50
+ selected = domain.to_s.strip
51
+ raise "tempmails-cc: 域名为空" if selected.empty?
52
+
53
+ EmailInfo.new(channel: channel, email: "#{random_local}@#{selected}")
54
+ end
55
+
56
+ # @param email [String]
57
+ # @return [Array<Email>]
58
+ def get_emails(email)
59
+ address = email.to_s.strip
60
+ raise "tempmails-cc: 邮箱地址为空" if address.empty?
61
+
62
+ data = get_json("#{BASE_URL}/api/inbox/#{CGI.escape(address).gsub('%40', '@')}")
63
+ (data["messages"] || []).filter_map do |item|
64
+ message_id = item["id"].to_s.strip
65
+ next if message_id.empty?
66
+
67
+ begin
68
+ detail = get_json("#{BASE_URL}/api/message/#{CGI.escape(message_id)}" \
69
+ "?address=#{CGI.escape(address).gsub('%40', '@')}&mark_read=false")
70
+ to = detail["to"].is_a?(Array) ? detail["to"].first : detail["to"]
71
+ next Normalize.normalize_email({
72
+ "id" => detail["id"] || message_id,
73
+ "from" => detail["from"], "to" => to || address,
74
+ "subject" => detail["subject"],
75
+ "text" => detail["textBody"], "html" => detail["htmlBody"],
76
+ "date" => detail["date"], "seen" => detail["isRead"]
77
+ }, address)
78
+ rescue StandardError
79
+ # 详情失败时退回摘要
80
+ end
81
+
82
+ Normalize.normalize_email({
83
+ "id" => message_id, "from" => item["from"], "to" => address,
84
+ "subject" => item["subject"], "date" => item["date"],
85
+ "seen" => item["isRead"]
86
+ }, address)
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "cgi"
4
+
5
+ module TempmailSdk
6
+ module Providers
7
+ # Tsukaisute Mail 渠道 — https://tsukaisutemail.com
8
+ # 无需密钥;创建随机地址后,地址即读取凭据。
9
+ module TsukaisuteMail
10
+ CHANNEL = "tsukaisutemail"
11
+ BASE_URL = "https://tsukaisutemail.com/api/v1"
12
+ HEADERS = { "Accept" => "application/json" }.freeze
13
+
14
+ module_function
15
+
16
+ def fetch_json(url)
17
+ resp = Http.get(url, headers: HEADERS, timeout: 20)
18
+ resp.raise_for_status
19
+ resp.json
20
+ end
21
+
22
+ # 创建 Tsukaisute Mail 临时地址
23
+ # @return [EmailInfo]
24
+ def generate_email
25
+ resp = Http.post("#{BASE_URL}/address", headers: HEADERS, timeout: 20)
26
+ resp.raise_for_status
27
+ address = resp.json["address"].to_s.strip
28
+ raise "tsukaisutemail: 创建响应缺少地址" if address.empty?
29
+
30
+ EmailInfo.new(channel: CHANNEL, email: address)
31
+ end
32
+
33
+ # @param email [String]
34
+ # @return [Array<Email>]
35
+ def get_emails(email)
36
+ address = email.to_s.strip
37
+ raise "tsukaisutemail: 邮箱地址为空" if address.empty?
38
+
39
+ data = fetch_json("#{BASE_URL}/inbox/#{CGI.escape(address).gsub("%40", "@")}")
40
+ (data["messages"] || []).filter_map do |item|
41
+ message_id = item["id"].to_s.strip
42
+ next if message_id.empty?
43
+
44
+ begin
45
+ detail = fetch_json("#{BASE_URL}/message/#{CGI.escape(message_id)}")
46
+ message = detail["message"]
47
+ if message.is_a?(Hash)
48
+ next Normalize.normalize_email({
49
+ "id" => message["id"], "from" => message["from_address"],
50
+ "to" => address, "subject" => message["subject"],
51
+ "text" => message["text_body"], "html" => message["html_body"],
52
+ "date" => message["received_at"]
53
+ }, address)
54
+ end
55
+ rescue StandardError
56
+ # 详情失败时退回摘要
57
+ end
58
+
59
+ Normalize.normalize_email({
60
+ "id" => message_id, "from" => item["from_address"], "to" => address,
61
+ "subject" => item["subject"], "text" => item["snippet"],
62
+ "date" => item["received_at"]
63
+ }, address)
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -55,7 +55,11 @@ module TempmailSdk
55
55
  Nukemail: "nukemail", Shadowmail: "shadowmail", Flybymail: "flybymail",
56
56
  Nowtempmail: "nowtempmail", Clawdemail: "clawdemail", Tempmail100: "tempmail100",
57
57
  Tempmailto: "tempmailto", TempMailGg: "temp_mail_gg",
58
- Tmpkit: "tmpkit", Internxt: "internxt", GeneratorEmail: "generator_email"
58
+ Tmpkit: "tmpkit", Internxt: "internxt", GeneratorEmail: "generator_email",
59
+ DummyInbox: "dummyinbox", PlainlyKit: "plainlykit", MailboxTemp: "mailboxtemp",
60
+ Nextmail: "nextmail", TsukaisuteMail: "tsukaisutemail", Tempmailify: "tempmailify",
61
+ Grabmail: "grabmail", TempmailsCc: "tempmails_cc", GeniusGSM: "geniusgsm",
62
+ TempTf: "temp_tf"
59
63
  }.freeze
60
64
 
61
65
  PROVIDER_AUTOLOADS.each do |mod_name, file|
@@ -956,6 +960,58 @@ module TempmailSdk
956
960
  generate: ->(_o) { with_channel(p::Duckmail.generate_email_at_domain("hubaiclass.org"), "hubaiclass-org") },
957
961
  get_emails: ->(e, t) { p::Duckmail.get_emails(e, require_token(t, "duckmail")) }
958
962
  },
963
+ "dummyinbox" => {
964
+ generate: ->(_o) { p::DummyInbox.generate_email },
965
+ get_emails: ->(e, _t) { p::DummyInbox.get_emails(e) }
966
+ },
967
+ "plainlykit" => {
968
+ generate: ->(_o) { p::PlainlyKit.generate_email },
969
+ get_emails: ->(e, t) { p::PlainlyKit.get_emails(e, require_token(t, "plainlykit")) }
970
+ },
971
+ "mailboxtemp" => {
972
+ generate: ->(_o) { p::MailboxTemp.generate_email },
973
+ get_emails: ->(e, _t) { p::MailboxTemp.get_emails(e) }
974
+ },
975
+ "nextmail" => {
976
+ generate: ->(_o) { p::Nextmail.generate_email },
977
+ get_emails: ->(e, t) { p::Nextmail.get_emails(e, require_token(t, "nextmail")) }
978
+ },
979
+ "tsukaisutemail" => {
980
+ generate: ->(_o) { p::TsukaisuteMail.generate_email },
981
+ get_emails: ->(e, _t) { p::TsukaisuteMail.get_emails(e) }
982
+ },
983
+ "tempmailify" => {
984
+ generate: ->(_o) { p::Tempmailify.generate_email },
985
+ get_emails: ->(e, t) { p::Tempmailify.get_emails(e, require_token(t, "tempmailify")) }
986
+ },
987
+ "grabmail" => {
988
+ generate: ->(_o) { p::Grabmail.generate_email },
989
+ get_emails: ->(e, _t) { p::Grabmail.get_emails(e) }
990
+ },
991
+ "tempmails-cc" => {
992
+ generate: ->(_o) { p::TempmailsCc.generate_email },
993
+ get_emails: ->(e, _t) { p::TempmailsCc.get_emails(e) }
994
+ },
995
+ "geniusgsm" => {
996
+ generate: ->(_o) { p::GeniusGSM.generate_email },
997
+ get_emails: ->(e, t) { p::GeniusGSM.get_emails(e, require_token(t, "geniusgsm")) }
998
+ },
999
+ "temp-tf" => {
1000
+ generate: ->(_o) { p::TempTf.generate_email },
1001
+ get_emails: ->(e, _t) { p::TempTf.get_emails(e) }
1002
+ },
1003
+ "anotherkevin-com" => {
1004
+ generate: lambda { |_o|
1005
+ p::TempmailsCc.generate_email_at_domain("anotherkevin.com", "anotherkevin-com")
1006
+ },
1007
+ get_emails: ->(e, _t) { p::TempmailsCc.get_emails(e) }
1008
+ },
1009
+ "alviongroup-cloud" => {
1010
+ generate: lambda { |_o|
1011
+ p::TempmailsCc.generate_email_at_domain("alviongroup.cloud", "alviongroup-cloud")
1012
+ },
1013
+ get_emails: ->(e, _t) { p::TempmailsCc.get_emails(e) }
1014
+ },
959
1015
  "mail10s" => {
960
1016
  generate: ->(_o) { p::Mail10s.generate_email },
961
1017
  get_emails: ->(e, _t) { p::Mail10s.get_emails(e) }
@@ -2,5 +2,5 @@
2
2
 
3
3
  module TempmailSdk
4
4
  # SDK 版本号
5
- VERSION = "1.3.6"
5
+ VERSION = "1.3.8"
6
6
  end
data/lib/tempmail_sdk.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # 临时邮箱 SDK (Ruby)
4
- # 聚合 290 个第三方临时邮箱渠道,所有渠道返回统一标准化格式。
4
+ # 聚合 316 个第三方临时邮箱渠道,所有渠道返回统一标准化格式。
5
5
  # 与 Go / npm / Rust / Python / C / PHP 各端共享相同的渠道标识与顺序。
6
6
 
7
7
  require_relative "tempmail_sdk/version"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tempmail_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.6
4
+ version: 1.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - tempmail-sdk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-11-11 00:00:00.000000000 Z
11
+ date: 2026-11-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 五端(Go/npm/Rust/Python/C)之外的 Ruby 版临时邮箱 SDK,共享相同的渠道标识与顺序,提供统一的 Email 结构、渠道
14
14
  fallback、代理/超时/TLS/遥测配置。
@@ -46,6 +46,7 @@ files:
46
46
  - lib/tempmail_sdk/providers/dropmail_click.rb
47
47
  - lib/tempmail_sdk/providers/dropmail_me.rb
48
48
  - lib/tempmail_sdk/providers/duckmail.rb
49
+ - lib/tempmail_sdk/providers/dummyinbox.rb
49
50
  - lib/tempmail_sdk/providers/email10min.rb
50
51
  - lib/tempmail_sdk/providers/emailnator.rb
51
52
  - lib/tempmail_sdk/providers/emailtemp_org.rb
@@ -59,7 +60,9 @@ files:
59
60
  - lib/tempmail_sdk/providers/fmail.rb
60
61
  - lib/tempmail_sdk/providers/freecustom.rb
61
62
  - lib/tempmail_sdk/providers/generator_email.rb
63
+ - lib/tempmail_sdk/providers/geniusgsm.rb
62
64
  - lib/tempmail_sdk/providers/getnada.rb
65
+ - lib/tempmail_sdk/providers/grabmail.rb
63
66
  - lib/tempmail_sdk/providers/guerrillamail.rb
64
67
  - lib/tempmail_sdk/providers/guerrillamail_mirrors.rb
65
68
  - lib/tempmail_sdk/providers/harakirimail.rb
@@ -79,6 +82,7 @@ files:
79
82
  - lib/tempmail_sdk/providers/mail_sunls.rb
80
83
  - lib/tempmail_sdk/providers/mail_td.rb
81
84
  - lib/tempmail_sdk/providers/mail_tm.rb
85
+ - lib/tempmail_sdk/providers/mailboxtemp.rb
82
86
  - lib/tempmail_sdk/providers/mailcat_ai.rb
83
87
  - lib/tempmail_sdk/providers/mailcatch.rb
84
88
  - lib/tempmail_sdk/providers/maildrop.rb
@@ -98,6 +102,7 @@ files:
98
102
  - lib/tempmail_sdk/providers/mytempmail_cc.rb
99
103
  - lib/tempmail_sdk/providers/neighbours.rb
100
104
  - lib/tempmail_sdk/providers/neighbours_sh.rb
105
+ - lib/tempmail_sdk/providers/nextmail.rb
101
106
  - lib/tempmail_sdk/providers/nimail.rb
102
107
  - lib/tempmail_sdk/providers/nowtempmail.rb
103
108
  - lib/tempmail_sdk/providers/noxen_de5_net.rb
@@ -106,6 +111,7 @@ files:
106
111
  - lib/tempmail_sdk/providers/ockito.rb
107
112
  - lib/tempmail_sdk/providers/one_sec_mail.rb
108
113
  - lib/tempmail_sdk/providers/openinbox.rb
114
+ - lib/tempmail_sdk/providers/plainlykit.rb
109
115
  - lib/tempmail_sdk/providers/restmail_net.rb
110
116
  - lib/tempmail_sdk/providers/rootsh.rb
111
117
  - lib/tempmail_sdk/providers/shadowmail.rb
@@ -119,6 +125,7 @@ files:
119
125
  - lib/tempmail_sdk/providers/temp_mail_gg.rb
120
126
  - lib/tempmail_sdk/providers/temp_mail_io.rb
121
127
  - lib/tempmail_sdk/providers/temp_mail_org.rb
128
+ - lib/tempmail_sdk/providers/temp_tf.rb
122
129
  - lib/tempmail_sdk/providers/tempemail_co.rb
123
130
  - lib/tempmail_sdk/providers/tempemail_info.rb
124
131
  - lib/tempmail_sdk/providers/tempemails_net.rb
@@ -138,8 +145,10 @@ files:
138
145
  - lib/tempmail_sdk/providers/tempmail_lol_v2.rb
139
146
  - lib/tempmail_sdk/providers/tempmail_plus.rb
140
147
  - lib/tempmail_sdk/providers/tempmailc.rb
148
+ - lib/tempmail_sdk/providers/tempmailify.rb
141
149
  - lib/tempmail_sdk/providers/tempmailportal.rb
142
150
  - lib/tempmail_sdk/providers/tempmailpro.rb
151
+ - lib/tempmail_sdk/providers/tempmails_cc.rb
143
152
  - lib/tempmail_sdk/providers/tempmails_io.rb
144
153
  - lib/tempmail_sdk/providers/tempmailten.rb
145
154
  - lib/tempmail_sdk/providers/tempmailto.rb
@@ -155,6 +164,7 @@ files:
155
164
  - lib/tempmail_sdk/providers/throwawaymail.rb
156
165
  - lib/tempmail_sdk/providers/tmail_link.rb
157
166
  - lib/tempmail_sdk/providers/tmpkit.rb
167
+ - lib/tempmail_sdk/providers/tsukaisutemail.rb
158
168
  - lib/tempmail_sdk/providers/twentyfourmail_chacuo.rb
159
169
  - lib/tempmail_sdk/providers/uncorreotemporal.rb
160
170
  - lib/tempmail_sdk/providers/vip_215.rb