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



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

def self.authors
  ["huangj"]
end

.available_optionsObject



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

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),
    FastlaneCore::ConfigItem.new(key: :target,
                          env_name: "SEND_E_MAIL_attachment",
                       description: "A description of attachment",
                          optional: true,
                              type: String)
  ]
end

.descriptionObject



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

def self.description
  "a tool to sendmail"
end

.detailsObject



56
57
58
59
# File 'lib/fastlane/plugin/send_e_mail/actions/send_e_mail_action.rb', line 56

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

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


107
108
109
110
111
112
113
114
# File 'lib/fastlane/plugin/send_e_mail/actions/send_e_mail_action.rb', line 107

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



52
53
54
# File 'lib/fastlane/plugin/send_e_mail/actions/send_e_mail_action.rb', line 52

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

.run(params) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fastlane/plugin/send_e_mail/actions/send_e_mail_action.rb', line 32

def self.run(params)
    self.send_emails(
      params[:stmp_server], 
      params[:user_name], 
      params[:password], 
      params[:recipients], 
      params[:subject], 
      params[:message_body],
      params[:attachment],
      params[:target])
end

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



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# 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, attachment, target)
  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_header << "MIME-Version: 1.0" + "\r\n"
    message_header << "Content-type: text/html;charset=utf-8" + "\r\n"
    message = message_header + "\r\n" + message_body.encode('utf-8') + "\r\n"
    Net::SMTP.start(stmpserver_address, 25, "yeah.net", sender_address, password, :plain) do |smtp|
      begin
        smtp.send_message(message, sender_address, recipient_address)
      rescue
        raise Exception => e
        print "Exception occured: " + e 
      end
    end
    
  end
end