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



106
107
108
# File 'lib/fastlane/plugin/gmail/actions/gmail_action.rb', line 106

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

.available_optionsObject



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
99
100
101
102
103
104
# File 'lib/fastlane/plugin/gmail/actions/gmail_action.rb', line 52

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: :cc,
                                 env_name: "FL_GMAIL_CC",
                                 description: "Mail cc recipients",
                                 sensitive: true,
                                 is_string: false),                             
    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



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

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

.detailsObject



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

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)


110
111
112
# File 'lib/fastlane/plugin/gmail/actions/gmail_action.rb', line 110

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
36
# 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]
    cc       params[:cc]
    subject  params[:subject]
    html_part do
      content_type 'text/html; charset=UTF-8'
      body params[:body]
    end
  end
end