Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Sequential Calls only sends to the first address #1

Open
bzh4bzh opened this issue Jan 8, 2019 · 1 comment
Open

Multiple Sequential Calls only sends to the first address #1

bzh4bzh opened this issue Jan 8, 2019 · 1 comment

Comments

@bzh4bzh
Copy link

bzh4bzh commented Jan 8, 2019

sms(A, 'tmobile', '[email protected]', PASSWORD, mms=True, subject=f"Test", contents=msg)
sms(B, 'tmobile', '[email protected]', PASSWORD, mms=True, subject=f"Test", contents=msg)
results in the message only being sent to A then prints out "[Errno 8] nodename nor servname provided, or not known Unhandled error sending mail." but is not caught in an except statement

@AdamTogether
Copy link

I also encountered this problem. Circumnavigated the issue by creating a separate Python helper file in the same directory as the main script and invoked the helper with os.system for each call.

(Note: the use of f-strings here requires Python version >= 3.6.)

Example call in main script:

os.system(f"python3 sms_helper.py \"{recipient}\" \"{subject}\" \"{message}\" \"{mms}\"")

Code from sms_helper.py:

#!/usr/bin/env python3

from mail_to_sms import MailToSMS
import sys


def send(recipient, subject, message, mms=False):
    print("Running sms_helper.send()...")
    print(f"recipient: {recipient}")
    print(f"subject: {subject}")
    print(f"message: {message}")
    print(f"mms: {mms}\n")
    MailToSMS(recipient, "verizon wireless", "[email protected]", subject=subject, contents=message, mms=mms)


if __name__ == '__main__':
    if len(sys.argv) == 5:
        send(str(sys.argv[1]), str(sys.argv[2]), str(sys.argv[3]), str(sys.argv[4]))
    elif len(sys.argv) == 4:
        send(str(sys.argv[1]), str(sys.argv[2]), str(sys.argv[3]))  
    else:
        print("No arguments given, sms not sent.")
        print("USAGE: python sms_helper.py [recipient=STRING] [subject=STRING] [message=STRING] [mms=BOOLEAN]")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants