andrewshilliday / garage-door-controller

Software to monitor and control garage doors via a raspberry pi
MIT License
327 stars 127 forks source link

Emails have no subject #15

Closed flare04 closed 7 years ago

flare04 commented 8 years ago

The emails are sent correctly but do not have a subject.

I'll try and suggest some code soon.

Pack3tL0ss commented 8 years ago

I added the subject on mine. My Function now looks like this

    def send_opendoor_message(self, opentime):
        syslog.syslog("Sending open door message. (%s)" % opentime)
        self.door_open_text = config["messaging"]["door_open_text"]
        config = self.config['smtp']
        server = smtplib.SMTP(config["smtphost"], config["smtpport"])
        if (config["smtp_tls"] == "True") :
            server.starttls()
        server.login(config["username"], config["password"])
        SUBJECT = "Garage Door Open"
        TEXT = self.door_open_text + " (%s)." % elapsed_time(opentime)
        message = 'Subject: %s\n\n%s' % (SUBJECT, TEXT)
        server.sendmail(config["username"], config["to_email"], message)
        server.close()
        self.msg_sent = True    
andrewshilliday commented 8 years ago

That's a good point. I've been using the emails to send SMS messages to phones, so a subject was not needed.

jkissner commented 7 years ago

I added in some lines to over come this issue. It now sends a full email. Let me know where I can send the new code if someone is interested.

DervMan commented 7 years ago

@jkissner Could you upload the code here so I can use it? Thanks

andrewshilliday commented 7 years ago

@jkissner, if you forked the code, you can issue a merge pull request and I can merge it back in. otherwise, just send me the relevant code snippet and I can add it to the master.