Esempio n. 1
0
	def setUp(self):
		self.sms = SMSMessage(
			"Body",
			VALID_FROM_NUMBER,
			[VALID_TO_NUMBER]
		)
		self.sms_no_recipients = SMSMessage("Body", VALID_TO_NUMBER, [])
Esempio n. 2
0
def PersonSendSmsView(request):
    TWILIO_MAGIC_FROM_NUMBER = "+15005550006"
    VALID_FROM_NUMBER = TWILIO_MAGIC_FROM_NUMBER
    VALID_TO_NUMBER = TWILIO_MAGIC_FROM_NUMBER
    sms = SMSMessage("Body", VALID_FROM_NUMBER, [VALID_TO_NUMBER])
    sms.send()

    send_sms("Body", VALID_FROM_NUMBER, [VALID_TO_NUMBER])

    return render(request, 'sms_sent.html')
Esempio n. 3
0
def send_sms(message, from_number, recipient_list, fail_silently=False, auth_user=None, auth_password=None, connection=None):
	"""
	Easy wrapper for sending a single message to a recipient list. All members
	of the recipient list will see the other recipients in the 'To' field.

	If auth_user is None, the EMAIL_HOST_USER setting is used.
	If auth_password is None, the EMAIL_HOST_PASSWORD setting is used.

	Note: The API for this method is frozen. New code wanting to extend the
	functionality should use the EmailMessage class directly.

	https://github.com/django/django/blob/master/django/core/mail/__init__.py#L40
	"""
	connection = connection or get_sms_connection(username=auth_user, password=auth_password, fail_silently=fail_silently)
	mail = SMSMessage(message, from_number, recipient_list, connection=connection)

	return mail.send()
Esempio n. 4
0
def send_mass_sms(datatuple, fail_silently=False, auth_user=None, auth_password=None, connection=None):
	"""
	Given a datatuple of (subject, message, from_email, recipient_list), sends
	each message to each recipient list. Returns the number of emails sent.

	If from_email is None, the DEFAULT_FROM_EMAIL setting is used.
	If auth_user and auth_password are set, they're used to log in.
	If auth_user is None, the EMAIL_HOST_USER setting is used.
	If auth_password is None, the EMAIL_HOST_PASSWORD setting is used.

	Note: The API for this method is frozen. New code wanting to extend the
	functionality should use the EmailMessage class directly.

	https://github.com/django/django/blob/master/django/core/mail/__init__.py#L64
	"""
	import smsish.sms.backends.rq
	if isinstance(connection, smsish.sms.backends.rq.SMSBackend):
		raise NotImplementedError
	connection = connection or get_sms_connection(username=auth_user, password=auth_password, fail_silently=fail_silently)
	messages = [SMSMessage(message, from_number, recipient, connection=connection) for message, from_number, recipient in datatuple]
	return connection.send_messages(messages)
Esempio n. 5
0
	def get_new_sms_message(self):
		return SMSMessage(
			"Body",
			VALID_FROM_NUMBER,
			[VALID_TO_NUMBER]
		)
Esempio n. 6
0
	def test_create_with_subject_not_allowed(self):
		with self.assertRaises(TypeError):
			SMSMessage("Subject", "Body", VALID_FROM_NUMBER, [VALID_TO_NUMBER])