Class | Yapra::Plugin::Publish::Smtp |
In: |
lib-plugins/yapra/plugin/publish/smtp.rb
|
Parent: |
sending each entry via smtp.
example:
- module: Publish::Smtp config: username: username password: password smtp_server: smtp.example.com helo: [example.com] pop_server: [pop.example.com] authtype: pop | apop | :plain | :cram_md5 port: 25 # or 587 wait: 1 mail: subject_prefix: '[Yapra]' from_template: <%=item.author%> <test@example.com> from: 'test@example.com' # use for envelope from to: 'test2@example.com'
MAIL_ADDRESS_FORMAT | = | /<([0-9a-z!#_\$%\&'\*\+\/\=\?\^\|\-\{\}\.]+@[0-9a-z!#_\$%\&'\*\+\/\=\?\^\|\-\{\}\.]+)>/ |
# File lib-plugins/yapra/plugin/publish/smtp.rb, line 64 64: def close_session 65: @session.finish 66: end
# File lib-plugins/yapra/plugin/publish/smtp.rb, line 49 49: def open_session 50: if ( config['pop_server'] ) 51: require 'net/pop' 52: apop = (config['authtype'] == 'apop') 53: Net::POP3.APOP(apop).auth_only(config['pop_server'], 110, config['username'], config['password']) 54: config['username'] = nil 55: config['password'] = nil 56: config['authtype'] = nil 57: end 58: logger.info( "Connecting server: #{config['smtp_server']}, port: #{config['port']}, helo_domain: #{config['helo']}, accout: #{config['username']}, authtype: #{config['authtype']}" ) 59: @session = Net::SMTP.start(config['smtp_server'], config['port'], 60: config['helo'], config['username'], 61: config['password'], config['authtype']) 62: end
# File lib-plugins/yapra/plugin/publish/smtp.rb, line 30 30: def prepare 31: super 32: config['helo'] = config['helo'] || 'localhost.localdomain' 33: if config['authtype'] 34: if ( config['pop_server'] ) 35: config['port'] = config['port'] || 25 36: config['authtype'] = config['authtype'] || 'pop' 37: else 38: config['port'] = config['port'] || 587 39: config['authtype'] = config['authtype'] || :plain 40: end 41: else 42: config['port'] = config['port'] || 25 43: config['pop_server'] = nil 44: config['username'] = nil 45: config['password'] = nil 46: end 47: end
# File lib-plugins/yapra/plugin/publish/smtp.rb, line 73 73: def raw_mail_address address 74: if MAIL_ADDRESS_FORMAT =~ address 75: address = $1 76: end 77: return address 78: end