class Fastlane::Actions::SendEMailAction

Public Class Methods

authors() click to toggle source
# File lib/fastlane/plugin/send_e_mail/actions/send_e_mail_action.rb, line 48
def self.authors
  ["huangj"]
end
available_options() click to toggle source
# 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
description() click to toggle source
# File lib/fastlane/plugin/send_e_mail/actions/send_e_mail_action.rb, line 44
def self.description
  "a tool to sendmail"
end
details() click to toggle source
# 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) click to toggle source
# 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_value() click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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