class EMail::ConcurrentSender


Utility object for concurrent email sending.

rcpt_list = ["", "", "", ""]

# Set SMTP client configuration
config ="", 25)

# Create concurrent sender object
sender =

# 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 =
    mail.from "" rcpt_to
    mail.subject "Concurrent email sending"
    mail.message "message to #{rcpt_to}"
    # Enqueue the email to sender
    enqueue mail

Defined in:



Instance Method Summary

Constructor Detail

def #

Create sender object with given client settings as EMail::Client::Config object.

[View source]
def*args, **named_args) #

Send one email with given client settings as several arguments.

Avairable arguments are same as EMail::Client::Conifg.create method.

[View source]

Instance Method Detail

def connection_interval=(new_interval : Int32) #

Set the interval milliseconds between some connection is closed and new one is opened.

[View source]
def enqueue(message : Message) #

Enqueue a email message.

[View source]
def enqueue(messages : Array(Message)) #

Encueue email messages at the same time.

[View source]
def messages_per_connection=(new_value : Int32) #

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.

[View source]
def number_of_connections=(new_value : Int32) #

Set the maximum number of SMTP connections established at the same time.

[View source]
def start(number_of_connections : Int32? = nil, messages_per_connection : Int32? = nil, connection_interval : Int32? = nil, &block) #

Starts sending emails with given parameters.

[View source]