class EMail::ConcurrentSender
- EMail::ConcurrentSender
- Reference
- Object
Overview
Utility object for concurrent email sending.
rcpt_list = ["[email protected]", "[email protected]", "[email protected]", "[email protected]"]
# Set SMTP client configuration
config = EMail::Client::Config.new("your.mx.example.com", 25)
# Create concurrent sender object
sender = EMail::ConcurrentSender.new(config)
# Sending emails with concurrently 3 connections.
sender.number_of_connections = 3
# Sending max 10 emails by 1 connection.
sender.messages_per_connection = 10
# Start email sending.
sender.start do
  # In this block, default receiver is sender
  rcpt_list.each do |rcpt_to|
    # Create email message
    mail = EMail::Message.new
    mail.from "[email protected]"
    mail.to rcpt_to
    mail.subject "Concurrent email sending"
    mail.message "message to #{rcpt_to}"
    # Enqueue the email to sender
    enqueue mail
  end
endDefined in:
email/concurrent_sender.crConstructors
- 
        .new(config : EMail::Client::Config)
        
          Create sender object with given client settings as EMail::Client::Config object. 
- 
        .new(*args, **named_args)
        
          Send one email with given client settings as several arguments. 
Instance Method Summary
- 
        #connection_interval=(new_interval : Int32)
        
          Set the interval milliseconds between some connection is closed and new one is opened. 
- 
        #enqueue(messages : Array(Message))
        
          Encueue email messages at the same time. 
- 
        #enqueue(message : Message)
        
          Enqueue a email message. 
- 
        #messages_per_connection=(new_value : Int32)
        
          Set the maximum number of email messages sent by one SMTP connection. 
- 
        #number_of_connections=(new_value : Int32)
        
          Set the maximum number of SMTP connections established at the same time. 
- 
        #start(number_of_connections : Int32 | Nil = nil, messages_per_connection : Int32 | Nil = nil, connection_interval : Int32 | Nil = nil, &)
        
          Starts sending emails with given parameters. 
Constructor Detail
Create sender object with given client settings as EMail::Client::Config object.
Send one email with given client settings as several arguments.
Avairable arguments are same as EMail::Client::Conifg.create method.
Instance Method Detail
Set the interval milliseconds between some connection is closed and new one is opened.
Set the maximum number of email messages sent by one SMTP connection.
When the number of sent emails by some SMTP connection reaches this parameter, the current connection will be closed and new one will be opened.
Set the maximum number of SMTP connections established at the same time.
Starts sending emails with given parameters.