Example #1
0
def send_parallel(DEFAULT, amount, count, wait, to_list, servers, host, port):
	xtra = 0

	_time = time.time()
	# Send emails
	for j in range(0, amount):	
		_xtra_time = time.time()
		# Create mail
		message = create_mail.create_mail(DEFAULT)
		# Display counter
		count += 1
		display_options.display_counter(DEFAULT['-c'], count)
		
		xtra_time = time.time() - _xtra_time
		xtra += xtra_time

		# Send emails
		send(DEFAULT, servers[j], to_list, message, count, host, port)
		# Delay	
		time.sleep(wait)
		
	# If want to disconnect, close the servers and reconnect
	if not (DEFAULT['-d']):
		for j in range(0, amount):
			disconnect(DEFAULT, servers[j], host, port)
			servers[j] = connect(DEFAULT, host, port)

	_time = time.time() - _time - xtra
	return count, _time
Example #2
0
def _series(DEFAULT, host, port):
	COUNT = 0
	time_xtra = 0
	
	wait = delay.delay(DEFAULT)
	to_list = recipient_count.create_recipient(DEFAULT['-t'], DEFAULT['-r'])
	
##    All the parameters that contains 'time' is to calculate the total time taken to Connect to server, Send mails, and Disconnect.
	
	time_st = time.time()
	# Connect to host	
	server = connect(DEFAULT, host, port)

	# If no message's body specified, send the email with default-message-body
	for j in range(0, DEFAULT['-m']):

		# Create email and display counter
		_time_xtra = time.time()
		message = create_mail.create_mail(DEFAULT)

		COUNT += 1
		display_options.display_counter(DEFAULT['-c'], COUNT)

		if (DEFAULT['-N']):
			to_list = recipient_count.change_recipient(DEFAULT['-t'], j)

		time_xtra += time.time() - _time_xtra

		# Send email
		send(DEFAULT, server, to_list, message, COUNT, host, port)
		# Delay
		time.sleep(wait)

		# If want to disconnect, quit server and reconnect for next message
		if (not DEFAULT['-d']) and (j < DEFAULT['-m']-1):
			disconnect(DEFAULT, server, host, port)
			server = connect(DEFAULT, host, port)

	disconnect(DEFAULT, server, host, port)

	time_elapse = time.time() - time_st - time_xtra
	return COUNT, time_elapse