Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../opt/alt/ruby27/share/ruby/net
File: smtp.rb
# frozen_string_literal: true
[0] Fix | Delete
# = net/smtp.rb
[1] Fix | Delete
#
[2] Fix | Delete
# Copyright (c) 1999-2007 Yukihiro Matsumoto.
[3] Fix | Delete
#
[4] Fix | Delete
# Copyright (c) 1999-2007 Minero Aoki.
[5] Fix | Delete
#
[6] Fix | Delete
# Written & maintained by Minero Aoki <aamine@loveruby.net>.
[7] Fix | Delete
#
[8] Fix | Delete
# Documented by William Webber and Minero Aoki.
[9] Fix | Delete
#
[10] Fix | Delete
# This program is free software. You can re-distribute and/or
[11] Fix | Delete
# modify this program under the same terms as Ruby itself.
[12] Fix | Delete
#
[13] Fix | Delete
# $Id$
[14] Fix | Delete
#
[15] Fix | Delete
# See Net::SMTP for documentation.
[16] Fix | Delete
#
[17] Fix | Delete
[18] Fix | Delete
require 'net/protocol'
[19] Fix | Delete
require 'digest/md5'
[20] Fix | Delete
require 'timeout'
[21] Fix | Delete
begin
[22] Fix | Delete
require 'openssl'
[23] Fix | Delete
rescue LoadError
[24] Fix | Delete
end
[25] Fix | Delete
[26] Fix | Delete
module Net
[27] Fix | Delete
[28] Fix | Delete
# Module mixed in to all SMTP error classes
[29] Fix | Delete
module SMTPError
[30] Fix | Delete
# This *class* is a module for backward compatibility.
[31] Fix | Delete
# In later release, this module becomes a class.
[32] Fix | Delete
end
[33] Fix | Delete
[34] Fix | Delete
# Represents an SMTP authentication error.
[35] Fix | Delete
class SMTPAuthenticationError < ProtoAuthError
[36] Fix | Delete
include SMTPError
[37] Fix | Delete
end
[38] Fix | Delete
[39] Fix | Delete
# Represents SMTP error code 4xx, a temporary error.
[40] Fix | Delete
class SMTPServerBusy < ProtoServerError
[41] Fix | Delete
include SMTPError
[42] Fix | Delete
end
[43] Fix | Delete
[44] Fix | Delete
# Represents an SMTP command syntax error (error code 500)
[45] Fix | Delete
class SMTPSyntaxError < ProtoSyntaxError
[46] Fix | Delete
include SMTPError
[47] Fix | Delete
end
[48] Fix | Delete
[49] Fix | Delete
# Represents a fatal SMTP error (error code 5xx, except for 500)
[50] Fix | Delete
class SMTPFatalError < ProtoFatalError
[51] Fix | Delete
include SMTPError
[52] Fix | Delete
end
[53] Fix | Delete
[54] Fix | Delete
# Unexpected reply code returned from server.
[55] Fix | Delete
class SMTPUnknownError < ProtoUnknownError
[56] Fix | Delete
include SMTPError
[57] Fix | Delete
end
[58] Fix | Delete
[59] Fix | Delete
# Command is not supported on server.
[60] Fix | Delete
class SMTPUnsupportedCommand < ProtocolError
[61] Fix | Delete
include SMTPError
[62] Fix | Delete
end
[63] Fix | Delete
[64] Fix | Delete
#
[65] Fix | Delete
# == What is This Library?
[66] Fix | Delete
#
[67] Fix | Delete
# This library provides functionality to send internet
[68] Fix | Delete
# mail via SMTP, the Simple Mail Transfer Protocol. For details of
[69] Fix | Delete
# SMTP itself, see [RFC2821] (http://www.ietf.org/rfc/rfc2821.txt).
[70] Fix | Delete
#
[71] Fix | Delete
# == What is This Library NOT?
[72] Fix | Delete
#
[73] Fix | Delete
# This library does NOT provide functions to compose internet mails.
[74] Fix | Delete
# You must create them by yourself. If you want better mail support,
[75] Fix | Delete
# try RubyMail or TMail or search for alternatives in
[76] Fix | Delete
# {RubyGems.org}[https://rubygems.org/] or {The Ruby
[77] Fix | Delete
# Toolbox}[https://www.ruby-toolbox.com/].
[78] Fix | Delete
#
[79] Fix | Delete
# FYI: the official documentation on internet mail is: [RFC2822] (http://www.ietf.org/rfc/rfc2822.txt).
[80] Fix | Delete
#
[81] Fix | Delete
# == Examples
[82] Fix | Delete
#
[83] Fix | Delete
# === Sending Messages
[84] Fix | Delete
#
[85] Fix | Delete
# You must open a connection to an SMTP server before sending messages.
[86] Fix | Delete
# The first argument is the address of your SMTP server, and the second
[87] Fix | Delete
# argument is the port number. Using SMTP.start with a block is the simplest
[88] Fix | Delete
# way to do this. This way, the SMTP connection is closed automatically
[89] Fix | Delete
# after the block is executed.
[90] Fix | Delete
#
[91] Fix | Delete
# require 'net/smtp'
[92] Fix | Delete
# Net::SMTP.start('your.smtp.server', 25) do |smtp|
[93] Fix | Delete
# # Use the SMTP object smtp only in this block.
[94] Fix | Delete
# end
[95] Fix | Delete
#
[96] Fix | Delete
# Replace 'your.smtp.server' with your SMTP server. Normally
[97] Fix | Delete
# your system manager or internet provider supplies a server
[98] Fix | Delete
# for you.
[99] Fix | Delete
#
[100] Fix | Delete
# Then you can send messages.
[101] Fix | Delete
#
[102] Fix | Delete
# msgstr = <<END_OF_MESSAGE
[103] Fix | Delete
# From: Your Name <your@mail.address>
[104] Fix | Delete
# To: Destination Address <someone@example.com>
[105] Fix | Delete
# Subject: test message
[106] Fix | Delete
# Date: Sat, 23 Jun 2001 16:26:43 +0900
[107] Fix | Delete
# Message-Id: <unique.message.id.string@example.com>
[108] Fix | Delete
#
[109] Fix | Delete
# This is a test message.
[110] Fix | Delete
# END_OF_MESSAGE
[111] Fix | Delete
#
[112] Fix | Delete
# require 'net/smtp'
[113] Fix | Delete
# Net::SMTP.start('your.smtp.server', 25) do |smtp|
[114] Fix | Delete
# smtp.send_message msgstr,
[115] Fix | Delete
# 'your@mail.address',
[116] Fix | Delete
# 'his_address@example.com'
[117] Fix | Delete
# end
[118] Fix | Delete
#
[119] Fix | Delete
# === Closing the Session
[120] Fix | Delete
#
[121] Fix | Delete
# You MUST close the SMTP session after sending messages, by calling
[122] Fix | Delete
# the #finish method:
[123] Fix | Delete
#
[124] Fix | Delete
# # using SMTP#finish
[125] Fix | Delete
# smtp = Net::SMTP.start('your.smtp.server', 25)
[126] Fix | Delete
# smtp.send_message msgstr, 'from@address', 'to@address'
[127] Fix | Delete
# smtp.finish
[128] Fix | Delete
#
[129] Fix | Delete
# You can also use the block form of SMTP.start/SMTP#start. This closes
[130] Fix | Delete
# the SMTP session automatically:
[131] Fix | Delete
#
[132] Fix | Delete
# # using block form of SMTP.start
[133] Fix | Delete
# Net::SMTP.start('your.smtp.server', 25) do |smtp|
[134] Fix | Delete
# smtp.send_message msgstr, 'from@address', 'to@address'
[135] Fix | Delete
# end
[136] Fix | Delete
#
[137] Fix | Delete
# I strongly recommend this scheme. This form is simpler and more robust.
[138] Fix | Delete
#
[139] Fix | Delete
# === HELO domain
[140] Fix | Delete
#
[141] Fix | Delete
# In almost all situations, you must provide a third argument
[142] Fix | Delete
# to SMTP.start/SMTP#start. This is the domain name which you are on
[143] Fix | Delete
# (the host to send mail from). It is called the "HELO domain".
[144] Fix | Delete
# The SMTP server will judge whether it should send or reject
[145] Fix | Delete
# the SMTP session by inspecting the HELO domain.
[146] Fix | Delete
#
[147] Fix | Delete
# Net::SMTP.start('your.smtp.server', 25,
[148] Fix | Delete
# 'mail.from.domain') { |smtp| ... }
[149] Fix | Delete
#
[150] Fix | Delete
# === SMTP Authentication
[151] Fix | Delete
#
[152] Fix | Delete
# The Net::SMTP class supports three authentication schemes;
[153] Fix | Delete
# PLAIN, LOGIN and CRAM MD5. (SMTP Authentication: [RFC2554])
[154] Fix | Delete
# To use SMTP authentication, pass extra arguments to
[155] Fix | Delete
# SMTP.start/SMTP#start.
[156] Fix | Delete
#
[157] Fix | Delete
# # PLAIN
[158] Fix | Delete
# Net::SMTP.start('your.smtp.server', 25, 'mail.from.domain',
[159] Fix | Delete
# 'Your Account', 'Your Password', :plain)
[160] Fix | Delete
# # LOGIN
[161] Fix | Delete
# Net::SMTP.start('your.smtp.server', 25, 'mail.from.domain',
[162] Fix | Delete
# 'Your Account', 'Your Password', :login)
[163] Fix | Delete
#
[164] Fix | Delete
# # CRAM MD5
[165] Fix | Delete
# Net::SMTP.start('your.smtp.server', 25, 'mail.from.domain',
[166] Fix | Delete
# 'Your Account', 'Your Password', :cram_md5)
[167] Fix | Delete
#
[168] Fix | Delete
class SMTP < Protocol
[169] Fix | Delete
[170] Fix | Delete
Revision = %q$Revision$.split[1]
[171] Fix | Delete
[172] Fix | Delete
# The default SMTP port number, 25.
[173] Fix | Delete
def SMTP.default_port
[174] Fix | Delete
25
[175] Fix | Delete
end
[176] Fix | Delete
[177] Fix | Delete
# The default mail submission port number, 587.
[178] Fix | Delete
def SMTP.default_submission_port
[179] Fix | Delete
587
[180] Fix | Delete
end
[181] Fix | Delete
[182] Fix | Delete
# The default SMTPS port number, 465.
[183] Fix | Delete
def SMTP.default_tls_port
[184] Fix | Delete
465
[185] Fix | Delete
end
[186] Fix | Delete
[187] Fix | Delete
class << self
[188] Fix | Delete
alias default_ssl_port default_tls_port
[189] Fix | Delete
end
[190] Fix | Delete
[191] Fix | Delete
def SMTP.default_ssl_context
[192] Fix | Delete
OpenSSL::SSL::SSLContext.new
[193] Fix | Delete
end
[194] Fix | Delete
[195] Fix | Delete
#
[196] Fix | Delete
# Creates a new Net::SMTP object.
[197] Fix | Delete
#
[198] Fix | Delete
# +address+ is the hostname or ip address of your SMTP
[199] Fix | Delete
# server. +port+ is the port to connect to; it defaults to
[200] Fix | Delete
# port 25.
[201] Fix | Delete
#
[202] Fix | Delete
# This method does not open the TCP connection. You can use
[203] Fix | Delete
# SMTP.start instead of SMTP.new if you want to do everything
[204] Fix | Delete
# at once. Otherwise, follow SMTP.new with SMTP#start.
[205] Fix | Delete
#
[206] Fix | Delete
def initialize(address, port = nil)
[207] Fix | Delete
@address = address
[208] Fix | Delete
@port = (port || SMTP.default_port)
[209] Fix | Delete
@esmtp = true
[210] Fix | Delete
@capabilities = nil
[211] Fix | Delete
@socket = nil
[212] Fix | Delete
@started = false
[213] Fix | Delete
@open_timeout = 30
[214] Fix | Delete
@read_timeout = 60
[215] Fix | Delete
@error_occurred = false
[216] Fix | Delete
@debug_output = nil
[217] Fix | Delete
@tls = false
[218] Fix | Delete
@starttls = false
[219] Fix | Delete
@ssl_context = nil
[220] Fix | Delete
end
[221] Fix | Delete
[222] Fix | Delete
# Provide human-readable stringification of class state.
[223] Fix | Delete
def inspect
[224] Fix | Delete
"#<#{self.class} #{@address}:#{@port} started=#{@started}>"
[225] Fix | Delete
end
[226] Fix | Delete
[227] Fix | Delete
#
[228] Fix | Delete
# Set whether to use ESMTP or not. This should be done before
[229] Fix | Delete
# calling #start. Note that if #start is called in ESMTP mode,
[230] Fix | Delete
# and the connection fails due to a ProtocolError, the SMTP
[231] Fix | Delete
# object will automatically switch to plain SMTP mode and
[232] Fix | Delete
# retry (but not vice versa).
[233] Fix | Delete
#
[234] Fix | Delete
attr_accessor :esmtp
[235] Fix | Delete
[236] Fix | Delete
# +true+ if the SMTP object uses ESMTP (which it does by default).
[237] Fix | Delete
alias :esmtp? :esmtp
[238] Fix | Delete
[239] Fix | Delete
# true if server advertises STARTTLS.
[240] Fix | Delete
# You cannot get valid value before opening SMTP session.
[241] Fix | Delete
def capable_starttls?
[242] Fix | Delete
capable?('STARTTLS')
[243] Fix | Delete
end
[244] Fix | Delete
[245] Fix | Delete
def capable?(key)
[246] Fix | Delete
return nil unless @capabilities
[247] Fix | Delete
@capabilities[key] ? true : false
[248] Fix | Delete
end
[249] Fix | Delete
private :capable?
[250] Fix | Delete
[251] Fix | Delete
# true if server advertises AUTH PLAIN.
[252] Fix | Delete
# You cannot get valid value before opening SMTP session.
[253] Fix | Delete
def capable_plain_auth?
[254] Fix | Delete
auth_capable?('PLAIN')
[255] Fix | Delete
end
[256] Fix | Delete
[257] Fix | Delete
# true if server advertises AUTH LOGIN.
[258] Fix | Delete
# You cannot get valid value before opening SMTP session.
[259] Fix | Delete
def capable_login_auth?
[260] Fix | Delete
auth_capable?('LOGIN')
[261] Fix | Delete
end
[262] Fix | Delete
[263] Fix | Delete
# true if server advertises AUTH CRAM-MD5.
[264] Fix | Delete
# You cannot get valid value before opening SMTP session.
[265] Fix | Delete
def capable_cram_md5_auth?
[266] Fix | Delete
auth_capable?('CRAM-MD5')
[267] Fix | Delete
end
[268] Fix | Delete
[269] Fix | Delete
def auth_capable?(type)
[270] Fix | Delete
return nil unless @capabilities
[271] Fix | Delete
return false unless @capabilities['AUTH']
[272] Fix | Delete
@capabilities['AUTH'].include?(type)
[273] Fix | Delete
end
[274] Fix | Delete
private :auth_capable?
[275] Fix | Delete
[276] Fix | Delete
# Returns supported authentication methods on this server.
[277] Fix | Delete
# You cannot get valid value before opening SMTP session.
[278] Fix | Delete
def capable_auth_types
[279] Fix | Delete
return [] unless @capabilities
[280] Fix | Delete
return [] unless @capabilities['AUTH']
[281] Fix | Delete
@capabilities['AUTH']
[282] Fix | Delete
end
[283] Fix | Delete
[284] Fix | Delete
# true if this object uses SMTP/TLS (SMTPS).
[285] Fix | Delete
def tls?
[286] Fix | Delete
@tls
[287] Fix | Delete
end
[288] Fix | Delete
[289] Fix | Delete
alias ssl? tls?
[290] Fix | Delete
[291] Fix | Delete
# Enables SMTP/TLS (SMTPS: SMTP over direct TLS connection) for
[292] Fix | Delete
# this object. Must be called before the connection is established
[293] Fix | Delete
# to have any effect. +context+ is a OpenSSL::SSL::SSLContext object.
[294] Fix | Delete
def enable_tls(context = SMTP.default_ssl_context)
[295] Fix | Delete
raise 'openssl library not installed' unless defined?(OpenSSL)
[296] Fix | Delete
raise ArgumentError, "SMTPS and STARTTLS is exclusive" if @starttls
[297] Fix | Delete
@tls = true
[298] Fix | Delete
@ssl_context = context
[299] Fix | Delete
end
[300] Fix | Delete
[301] Fix | Delete
alias enable_ssl enable_tls
[302] Fix | Delete
[303] Fix | Delete
# Disables SMTP/TLS for this object. Must be called before the
[304] Fix | Delete
# connection is established to have any effect.
[305] Fix | Delete
def disable_tls
[306] Fix | Delete
@tls = false
[307] Fix | Delete
@ssl_context = nil
[308] Fix | Delete
end
[309] Fix | Delete
[310] Fix | Delete
alias disable_ssl disable_tls
[311] Fix | Delete
[312] Fix | Delete
# Returns truth value if this object uses STARTTLS.
[313] Fix | Delete
# If this object always uses STARTTLS, returns :always.
[314] Fix | Delete
# If this object uses STARTTLS when the server support TLS, returns :auto.
[315] Fix | Delete
def starttls?
[316] Fix | Delete
@starttls
[317] Fix | Delete
end
[318] Fix | Delete
[319] Fix | Delete
# true if this object uses STARTTLS.
[320] Fix | Delete
def starttls_always?
[321] Fix | Delete
@starttls == :always
[322] Fix | Delete
end
[323] Fix | Delete
[324] Fix | Delete
# true if this object uses STARTTLS when server advertises STARTTLS.
[325] Fix | Delete
def starttls_auto?
[326] Fix | Delete
@starttls == :auto
[327] Fix | Delete
end
[328] Fix | Delete
[329] Fix | Delete
# Enables SMTP/TLS (STARTTLS) for this object.
[330] Fix | Delete
# +context+ is a OpenSSL::SSL::SSLContext object.
[331] Fix | Delete
def enable_starttls(context = SMTP.default_ssl_context)
[332] Fix | Delete
raise 'openssl library not installed' unless defined?(OpenSSL)
[333] Fix | Delete
raise ArgumentError, "SMTPS and STARTTLS is exclusive" if @tls
[334] Fix | Delete
@starttls = :always
[335] Fix | Delete
@ssl_context = context
[336] Fix | Delete
end
[337] Fix | Delete
[338] Fix | Delete
# Enables SMTP/TLS (STARTTLS) for this object if server accepts.
[339] Fix | Delete
# +context+ is a OpenSSL::SSL::SSLContext object.
[340] Fix | Delete
def enable_starttls_auto(context = SMTP.default_ssl_context)
[341] Fix | Delete
raise 'openssl library not installed' unless defined?(OpenSSL)
[342] Fix | Delete
raise ArgumentError, "SMTPS and STARTTLS is exclusive" if @tls
[343] Fix | Delete
@starttls = :auto
[344] Fix | Delete
@ssl_context = context
[345] Fix | Delete
end
[346] Fix | Delete
[347] Fix | Delete
# Disables SMTP/TLS (STARTTLS) for this object. Must be called
[348] Fix | Delete
# before the connection is established to have any effect.
[349] Fix | Delete
def disable_starttls
[350] Fix | Delete
@starttls = false
[351] Fix | Delete
@ssl_context = nil
[352] Fix | Delete
end
[353] Fix | Delete
[354] Fix | Delete
# The address of the SMTP server to connect to.
[355] Fix | Delete
attr_reader :address
[356] Fix | Delete
[357] Fix | Delete
# The port number of the SMTP server to connect to.
[358] Fix | Delete
attr_reader :port
[359] Fix | Delete
[360] Fix | Delete
# Seconds to wait while attempting to open a connection.
[361] Fix | Delete
# If the connection cannot be opened within this time, a
[362] Fix | Delete
# Net::OpenTimeout is raised. The default value is 30 seconds.
[363] Fix | Delete
attr_accessor :open_timeout
[364] Fix | Delete
[365] Fix | Delete
# Seconds to wait while reading one block (by one read(2) call).
[366] Fix | Delete
# If the read(2) call does not complete within this time, a
[367] Fix | Delete
# Net::ReadTimeout is raised. The default value is 60 seconds.
[368] Fix | Delete
attr_reader :read_timeout
[369] Fix | Delete
[370] Fix | Delete
# Set the number of seconds to wait until timing-out a read(2)
[371] Fix | Delete
# call.
[372] Fix | Delete
def read_timeout=(sec)
[373] Fix | Delete
@socket.read_timeout = sec if @socket
[374] Fix | Delete
@read_timeout = sec
[375] Fix | Delete
end
[376] Fix | Delete
[377] Fix | Delete
#
[378] Fix | Delete
# WARNING: This method causes serious security holes.
[379] Fix | Delete
# Use this method for only debugging.
[380] Fix | Delete
#
[381] Fix | Delete
# Set an output stream for debug logging.
[382] Fix | Delete
# You must call this before #start.
[383] Fix | Delete
#
[384] Fix | Delete
# # example
[385] Fix | Delete
# smtp = Net::SMTP.new(addr, port)
[386] Fix | Delete
# smtp.set_debug_output $stderr
[387] Fix | Delete
# smtp.start do |smtp|
[388] Fix | Delete
# ....
[389] Fix | Delete
# end
[390] Fix | Delete
#
[391] Fix | Delete
def debug_output=(arg)
[392] Fix | Delete
@debug_output = arg
[393] Fix | Delete
end
[394] Fix | Delete
[395] Fix | Delete
alias set_debug_output debug_output=
[396] Fix | Delete
[397] Fix | Delete
#
[398] Fix | Delete
# SMTP session control
[399] Fix | Delete
#
[400] Fix | Delete
[401] Fix | Delete
#
[402] Fix | Delete
# Creates a new Net::SMTP object and connects to the server.
[403] Fix | Delete
#
[404] Fix | Delete
# This method is equivalent to:
[405] Fix | Delete
#
[406] Fix | Delete
# Net::SMTP.new(address, port).start(helo_domain, account, password, authtype)
[407] Fix | Delete
#
[408] Fix | Delete
# === Example
[409] Fix | Delete
#
[410] Fix | Delete
# Net::SMTP.start('your.smtp.server') do |smtp|
[411] Fix | Delete
# smtp.send_message msgstr, 'from@example.com', ['dest@example.com']
[412] Fix | Delete
# end
[413] Fix | Delete
#
[414] Fix | Delete
# === Block Usage
[415] Fix | Delete
#
[416] Fix | Delete
# If called with a block, the newly-opened Net::SMTP object is yielded
[417] Fix | Delete
# to the block, and automatically closed when the block finishes. If called
[418] Fix | Delete
# without a block, the newly-opened Net::SMTP object is returned to
[419] Fix | Delete
# the caller, and it is the caller's responsibility to close it when
[420] Fix | Delete
# finished.
[421] Fix | Delete
#
[422] Fix | Delete
# === Parameters
[423] Fix | Delete
#
[424] Fix | Delete
# +address+ is the hostname or ip address of your smtp server.
[425] Fix | Delete
#
[426] Fix | Delete
# +port+ is the port to connect to; it defaults to port 25.
[427] Fix | Delete
#
[428] Fix | Delete
# +helo+ is the _HELO_ _domain_ provided by the client to the
[429] Fix | Delete
# server (see overview comments); it defaults to 'localhost'.
[430] Fix | Delete
#
[431] Fix | Delete
# The remaining arguments are used for SMTP authentication, if required
[432] Fix | Delete
# or desired. +user+ is the account name; +secret+ is your password
[433] Fix | Delete
# or other authentication token; and +authtype+ is the authentication
[434] Fix | Delete
# type, one of :plain, :login, or :cram_md5. See the discussion of
[435] Fix | Delete
# SMTP Authentication in the overview notes.
[436] Fix | Delete
#
[437] Fix | Delete
# === Errors
[438] Fix | Delete
#
[439] Fix | Delete
# This method may raise:
[440] Fix | Delete
#
[441] Fix | Delete
# * Net::SMTPAuthenticationError
[442] Fix | Delete
# * Net::SMTPServerBusy
[443] Fix | Delete
# * Net::SMTPSyntaxError
[444] Fix | Delete
# * Net::SMTPFatalError
[445] Fix | Delete
# * Net::SMTPUnknownError
[446] Fix | Delete
# * Net::OpenTimeout
[447] Fix | Delete
# * Net::ReadTimeout
[448] Fix | Delete
# * IOError
[449] Fix | Delete
#
[450] Fix | Delete
def SMTP.start(address, port = nil, helo = 'localhost',
[451] Fix | Delete
user = nil, secret = nil, authtype = nil,
[452] Fix | Delete
&block) # :yield: smtp
[453] Fix | Delete
new(address, port).start(helo, user, secret, authtype, &block)
[454] Fix | Delete
end
[455] Fix | Delete
[456] Fix | Delete
# +true+ if the SMTP session has been started.
[457] Fix | Delete
def started?
[458] Fix | Delete
@started
[459] Fix | Delete
end
[460] Fix | Delete
[461] Fix | Delete
#
[462] Fix | Delete
# Opens a TCP connection and starts the SMTP session.
[463] Fix | Delete
#
[464] Fix | Delete
# === Parameters
[465] Fix | Delete
#
[466] Fix | Delete
# +helo+ is the _HELO_ _domain_ that you'll dispatch mails from; see
[467] Fix | Delete
# the discussion in the overview notes.
[468] Fix | Delete
#
[469] Fix | Delete
# If both of +user+ and +secret+ are given, SMTP authentication
[470] Fix | Delete
# will be attempted using the AUTH command. +authtype+ specifies
[471] Fix | Delete
# the type of authentication to attempt; it must be one of
[472] Fix | Delete
# :login, :plain, and :cram_md5. See the notes on SMTP Authentication
[473] Fix | Delete
# in the overview.
[474] Fix | Delete
#
[475] Fix | Delete
# === Block Usage
[476] Fix | Delete
#
[477] Fix | Delete
# When this methods is called with a block, the newly-started SMTP
[478] Fix | Delete
# object is yielded to the block, and automatically closed after
[479] Fix | Delete
# the block call finishes. Otherwise, it is the caller's
[480] Fix | Delete
# responsibility to close the session when finished.
[481] Fix | Delete
#
[482] Fix | Delete
# === Example
[483] Fix | Delete
#
[484] Fix | Delete
# This is very similar to the class method SMTP.start.
[485] Fix | Delete
#
[486] Fix | Delete
# require 'net/smtp'
[487] Fix | Delete
# smtp = Net::SMTP.new('smtp.mail.server', 25)
[488] Fix | Delete
# smtp.start(helo_domain, account, password, authtype) do |smtp|
[489] Fix | Delete
# smtp.send_message msgstr, 'from@example.com', ['dest@example.com']
[490] Fix | Delete
# end
[491] Fix | Delete
#
[492] Fix | Delete
# The primary use of this method (as opposed to SMTP.start)
[493] Fix | Delete
# is probably to set debugging (#set_debug_output) or ESMTP
[494] Fix | Delete
# (#esmtp=), which must be done before the session is
[495] Fix | Delete
# started.
[496] Fix | Delete
#
[497] Fix | Delete
# === Errors
[498] Fix | Delete
#
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function