I’m creating a Python mailing List, but I had a problem at the end of function.
Problem is, the List must be like this:
['first@google.com', 'second@google.com', 'third@google.com']
My current code:
mailinputs = raw_input('Enter all mails with comma: ')
receivers = [mailinputs]
If you type:
'first@google.com', 'second@google.com', 'third@google.com'
An error comes up like this:
Probe failed: Illegal envelope To: address (invalid domain name):
Else, If you type:
first@google.com, second@google.com, third@google.com
Only first@google.com receives the mail.
What should I do?
The return of
raw_input()is a string. You need to split it on the comma, then you’ll get a list:So in your example:
Another step can be done to remove any whitespace before/after each email: