<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def Emailer(recipients, sender=None):
 """ Sends messages as emails to the given list of recipients. """

    import smtplib
    hostname = socket.gethostname()
    if not sender:
        sender = 'lggr@{0}'.format(hostname)
    smtp = smtplib.SMTP('localhost')
    try:
        while True:
            logstr = (yield)
            try:
                smtp.sendmail(sender, recipients, logstr)
            except smtplib.SMTPException:
                pass
    except GeneratorExit:
        smtp.quit()