Merrigan wrote:
> I am writing a script to administer my E-Mail Server. The One thing
> I'm currently struggling with is kind of Parsing the E-Mail adress
> that I supply to the script.
>
> I need to get the username (The part BEFORE the @ sign) out of the
> address so that I can use it elsewhere. The problem I have with this
> is that both the domain, and the username are variable lenghts and
> that I have no idea how to split the two parts.
>
> Is there any way that I can do this?
>
> Thank ye very much.
>>> addr = "[EMAIL PROTECTED]"
>>> addr.split("@")
['user', 'example.com']
If it's formatted like a To header ("User <[EMAIL PROTECTED]>"), use
email.Utils.parseaddr() to get the address out of it.\
The email modules might help you a lot:
<http://docs.python.org/lib/module-email.html>
--
--
http://mail.python.org/mailman/listinfo/python-list