Email Directly from python
Martin P. Hellwig
xng at xs4all.nl
Wed Feb 13 15:59:59 EST 2008
Larry Bates wrote:
> brad wrote:
>> I'd like to send email directly from within python without having to
>> rely on an external smtp server. You know, something like the good,
>> old Unix...
>>
>> echo My_message | mail -s Subject person at someplace.com
>>
>> Can Python do something similar in a portable fashion without a smtp
>> server installed on the machine?
>>
>> Thanks,
>> Brad
>
> smtp module can do what you want yes.
>
> -Larry
The tricky part is how to resolve the mail server for a mail address.
Usually you have to query the mx record of that domain. I solved that by
looking if I can find the nslookup binary.
I already wrote a command line mailer that can do attachments too, no
need to write it again. If anybody is interested I can open-source it.
--
mph
More information about the Python-list
mailing list