Class: Fastlane::Actions::GmailAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/gmail/actions/gmail_action.rb

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



100
101
102
# File 'lib/fastlane/plugin/gmail/actions/gmail_action.rb', line 100

def self.authors
  ["Alexander-Ignition"]
end

.available_optionsObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/fastlane/plugin/gmail/actions/gmail_action.rb', line 51

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :domain,
                                 env_name: "FL_GMAIL_DOMAIN",
                                 description: "G Suite domain",
                                 optional: true,
                                 default_value: "gmail.com",
                                 verify_block: proc do |value|
                                   UI.user_error!("No domain") if value.to_s.length == 0
                                 end),
    FastlaneCore::ConfigItem.new(key: :username,
                                 env_name: "FL_GMAIL_USERNAME",
                                 description: "Username for gmail",
                                 verify_block: proc do |value|
                                   UI.user_error!("No username") if value.to_s.length == 0
                                 end),
    FastlaneCore::ConfigItem.new(key: :password,
                                 env_name: "FL_GMAIL_PASSWORD",
                                 description: "Password for gmail",
                                 optional: true,
                                 sensitive: true,
                                 verify_block: proc do |value|
                                   UI.user_error!("No password") if value.to_s.length == 0
                                 end),
    FastlaneCore::ConfigItem.new(key: :to,
                                 env_name: "FL_GMAIL_TO",
                                 description: "Mail to recipients",
                                 sensitive: true,
                                 is_string: false,
                                 verify_block: proc do |value|
                                   UI.user_error!("No recipients") if value.to_s.length == 0
                                 end),
    FastlaneCore::ConfigItem.new(key: :subject,
                                 env_name: "FL_GMAIL_SUBJECT",
                                 description: "The subject of the email",
                                 sensitive: true,
                                 verify_block: proc do |value|
                                   UI.user_error!("No subject of email") if value.to_s.length == 0
                                 end),
    FastlaneCore::ConfigItem.new(key: :body,
                                 env_name: "FL_GMAIL_BODY",
                                 description: "The body of the email",
                                 sensitive: true,
                                 verify_block: proc do |value|
                                   UI.user_error!("No body of email") if value.to_s.length == 0
                                 end)
  ]
end

.descriptionObject



41
42
43
# File 'lib/fastlane/plugin/gmail/actions/gmail_action.rb', line 41

def self.description
  "A short description with <= 80 characters of what this action does"
end

.detailsObject



45
46
47
48
49
# File 'lib/fastlane/plugin/gmail/actions/gmail_action.rb', line 45

def self.details
  # Optional:
  # this is your chance to provide a more detailed description of this action
  "You can use this action to do cool things..."
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


104
105
106
# File 'lib/fastlane/plugin/gmail/actions/gmail_action.rb', line 104

def self.is_supported?(platform)
  true
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fastlane/plugin/gmail/actions/gmail_action.rb', line 4

def self.run(params)
  require 'mail'

  Mail.defaults do
    if params[:password]
      delivery_method :smtp, {
        address:              'smtp.gmail.com',
        port:                 587,
        user_name:            params[:username],
        password:             params[:password],
        authentication:       'plain',
        enable_starttls_auto: true
      }
    else
      delivery_method :smtp, {
        port: 587,
        address: "smtp-relay.gmail.com",
        domain: params[:domain]
      }
    end
  end

  Mail.deliver do
    from     params[:username]
    to       params[:to]
    subject  params[:subject]
    html_part do
      content_type 'text/html; charset=UTF-8'
      body params[:body]
    end
  end
end