Class: Fastlane::Actions::SendEMailAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



40
41
42
# File 'lib/fastlane/plugin/send_e_mail/actions/send_e_mail_action.rb', line 40

def self.authors
  ["huangj"]
end

.available_optionsObject



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
# File 'lib/fastlane/plugin/send_e_mail/actions/send_e_mail_action.rb', line 53

def self.available_options
  [
    # stmp servername
    FastlaneCore::ConfigItem.new(key: :stmp_server,
                            env_name: "SEND_E_MAIL_STMP_SERVER",
                         description: "servername",
                            optional: false,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :user_name,
                            env_name: "SEND_E_MAIL_USERNAME",
                         description: "USERNAME",
                            optional: false,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :password,
                            env_name: "SEND_E_MAIL_PASSWORD",
                         description: "password",
                            optional: false,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :recipients,
                          env_name: "SEND_E_MAIL_YOUR_OPTION",
                       description: "recipients",
                          optional: false,
                              type: Array),
    FastlaneCore::ConfigItem.new(key: :subject,
                          env_name: "SEND_E_MAIL_YOUR_OPTION",
                       description: "subject",
                          optional: true,
                              type: String),
    FastlaneCore::ConfigItem.new(key: :message_body,
                          env_name: "SEND_E_MAIL_YOUR_OPTION",
                       description: "message_body",
                          optional: true,
                              type: String),
    FastlaneCore::ConfigItem.new(key: :attachment,
                          env_name: "SEND_E_MAIL_attachment",
                       description: "A description of attachment",
                          optional: true,
                              type: String)
  ]
end

.descriptionObject



36
37
38
# File 'lib/fastlane/plugin/send_e_mail/actions/send_e_mail_action.rb', line 36

def self.description
  "a tool to sendmail"
end

.detailsObject



48
49
50
51
# File 'lib/fastlane/plugin/send_e_mail/actions/send_e_mail_action.rb', line 48

def self.details
  # Optional:
  "send email by stmp"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


94
95
96
97
98
99
100
101
# File 'lib/fastlane/plugin/send_e_mail/actions/send_e_mail_action.rb', line 94

def self.is_supported?(platform)
  # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
  # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
  #
  # [:ios, :mac, :android].include?(platform)
  [:ios, :mac].include?(platform)
  true
end

.return_valueObject



44
45
46
# File 'lib/fastlane/plugin/send_e_mail/actions/send_e_mail_action.rb', line 44

def self.return_value
  # If your method provides a return value, you can describe here what it does
end

.run(params) ⇒ Object



29
30
31
32
33
34
# File 'lib/fastlane/plugin/send_e_mail/actions/send_e_mail_action.rb', line 29

def self.run(params)
    # @params = params
    # UI.message("The send_e_mail plugin is working!")
    # self.send_emails(params[:stmpServer], params[:userName], params[:password], @params[:recipients], params[:subject], params[:message_body])
    self.send_emails(params[:stmp_server], params[:user_name], params[:password], params[:recipients], params[:subject], params[:message_body])
end

.send_emails(stmpserver_address, sender_address, password, recipients, subject, message_body) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fastlane/plugin/send_e_mail/actions/send_e_mail_action.rb', line 10

def self.send_emails(stmpserver_address, sender_address, password, recipients, subject, message_body)
  recipients.each do |recipient_address|
    message_header = ''
    message_header << "From: <#{sender_address}>\r\n"
    message_header << "To: <#{recipient_address}>\r\n"
    message_header << "Subject: #{subject}\r\n"
    message_header << "Date: " + Time.now.to_s + "\r\n"
    message = message_header + "\r\n" + message_body + "\r\n"
    Net::SMTP.start(stmpserver_address, 25, "localhost", sender_address, password, :plain) do |smtp|
      # begin
      smtp.send_message(message, sender_address, recipient_address)
      # rescue
      #   raise FileSaveError, $!
      # end
    end
    
  end
end