Start local SMTP server

Install SMTP Server · In Server Manager, select Features, and select Add Features. · In Add Features, select SMTP Server. If prompted, select Add ...

Start local SMTP server

Trying to write code that can send mail to anyone is problematic, because smtplib connects to servers client-to-server style rather than server-to-server-relay style.

But if you only need to send mail to one particular server, which you control, it's trivial. Just configure your server at 'mail.example.com' to accept any mail from 'crash-reports@example.com' to 'crash-reports@example.com'.

Your code will look something like this:

import smtplib
addr = 'crash-reports@example.com'
def send_crash_report(crash_report):
    msg = ('From: {}\r\nTo: {}\r\n\r\n{}'.format(
           addr, addr, crash_report)
    server = smtplib.SMTP('mail.example.com')
    server.sendmail(addr, [addr], msg)
    server.quit()

As a side note, if you're just starting on a crash report collector, you may want to consider using a web service instead of a mail address. You're going to run into problems with people who can't access port 25 through their corporate firewall/proxy, write code that extracts the crash reports from an inbox (and/or searches via IMAP or mbox or whatever), deal with spammers who somehow find crash-reports@example.com and flood it with 900 messages about Cialis for each actual crash report, etc.


Click Here to Visit

What's Your Reaction?

like
0
dislike
0
love
0
funny
0
angry
0
sad
0
wow
0