Class: HIO

Inherits:
Object
  • Object
show all
Defined in:
lib/hmisc/hio.rb

Constant Summary collapse

@@indentSpace =
0

Class Method Summary collapse

Class Method Details

.gmailOptions(username, password) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/hmisc/hio.rb', line 62

def self.gmailOptions(username, password) 

  return options = { 
    :address              => "smtp.gmail.com",
    :port                 => 587,
    :user_name            => username,
    :password             => password,
    :authentication       => 'plain',
    :enable_starttls_auto => true  
  }

end

.gmxOptions(username, password) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/hmisc/hio.rb', line 76

def self.gmxOptions(username, password) 

  return options = { 
    :address              => "mail.gmx.com",
    :port                 => 587,
    :user_name            => username,
    :password             => password,
    :authentication       => 'plain',
    :enable_starttls_auto => true
  }

end

.htmlEcholn(str) ⇒ Object



25
26
27
28
29
# File 'lib/hmisc/hio.rb', line 25

def self.htmlEcholn(str)
  return "" if (str == "")
  #return str.to_s
  return str.to_s + "\n"
end

.htmlEcholnCloseBlock(str) ⇒ Object



39
40
41
42
43
44
# File 'lib/hmisc/hio.rb', line 39

def self.htmlEcholnCloseBlock(str)

  @@indentSpace -= 1
  return self.htmlEcholn(str);

end

.htmlEcholnOpenBlock(str) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/hmisc/hio.rb', line 31

def self.htmlEcholnOpenBlock(str)

  result = self.htmlEcholn(str)
  @@indentSpace += 1
  return result

end

.isQuoted(str) ⇒ Object



50
51
52
53
54
# File 'lib/hmisc/hio.rb', line 50

def self.isQuoted(str) 

  return (str[0] == "'" && str[-1] == "'")

end

.options(emailFrom, emailPassword) ⇒ Object



89
90
91
92
93
94
95
# File 'lib/hmisc/hio.rb', line 89

def self.options(emailFrom, emailPassword)
  
  provider = emailFrom[emailFrom.index('@') + 1, emailFrom.size - 1]
  return self.gmxOptions(emailFrom, emailPassword) if(provider == "gmx.com")
  return self.gmailOptions(emailFrom, emailPassword) if(provider == "gmail.com")

end

.quote(str) ⇒ Object



46
47
48
# File 'lib/hmisc/hio.rb', line 46

def self.quote(str) 
  return "'#{str}'";
end

.sendEmail(emailFrom, emailTo, emailSubject, emailBody, emailPassword = "quickorder", emailFromName = "") ⇒ Object



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/hmisc/hio.rb', line 98

def self.sendEmail(emailFrom, emailTo, emailSubject, emailBody, emailPassword = "quickorder", emailFromName = "") 

  Mail.defaults do
    delivery_method :smtp, self.options(emailFrom, emailPassword)
  end

  Mail.deliver do
    to emailTo
    from emailFrom 
    subject emailSubject
    body emailBody
  end



=begin
message = <<MESSAGE_END
From: Private Person <[email protected]>
To: A Test User <[email protected]>
Subject: SMTP e-mail test

This is a test e-mail message.
MESSAGE_END

Net::SMTP.start('smtp.gmx.com', 465, 'localhost', '[email protected]', 'quickorder', :plain) do |smtp|
smtp.send_message message, '[email protected]', 
                           '[email protected]'
end


  provider = substr($emailFrom, strpos($emailFrom, '@') + 1);

  if(provider == "gmx.com")
    phpMailer = HIO::gmxPHPmailer();
  else
    phpMailer = HIO::gmailPHPmailer();

    phpMailer->Username = emailFrom;
    phpMailer->Password = password;
=end

end

.unQuote(str) ⇒ Object



56
57
58
59
60
# File 'lib/hmisc/hio.rb', line 56

def self.unQuote(str) 

  return isQuoted(str) ? str[1..-2] : str

end