Wake&smtp updates#20
Conversation
morrisonbrett
left a comment
There was a problem hiding this comment.
Nice work and thanks for contributing! A few changes and I'll take another look, and then merge.
| } | ||
| // | ||
| // Brett Morrison, Februrary 2016 | ||
| // Lee Elson. June 2020 Modified to add Tesla wake up call with sleep time and to have a complete TO:, FROM:, SUBJECT:,MSG |
There was a problem hiding this comment.
Should be:
// Lee Elson, June 2020
// Modified...
| // | ||
| // Brett Morrison, Februrary 2016 | ||
| // Lee Elson. June 2020 Modified to add Tesla wake up call with sleep time and to have a complete TO:, FROM:, SUBJECT:,MSG | ||
| // in the message portion of the sendmail. This is necessary for some SMPT servers. Also commented out texting portion |
| flag.StringVar(&mailServerLogin, "mailServerLogin", "", "SMTP Server login username") | ||
| flag.StringVar(&mailServerPassword, "mailServerPassword", "", "SMTP Server password") | ||
| flag.StringVar(&fromAddress, "fromAddress", "", "Alert send from email") | ||
| flag.StringVar(&toAddress1, "toAddress1", "", "Alert send to email1") //LSE mod to add second email address |
There was a problem hiding this comment.
Remove all // LSE comments. They won't age well. The nature of Git / GitHub history tells the story.
| logger.Println(err) | ||
| os.Exit(1) | ||
| } | ||
| time.Sleep(60 * time.Second) //Give it a chance to wake up LSE |
There was a problem hiding this comment.
Remove LSE from all comments except at the top
| } | ||
|
|
||
| // Need to set this flag for every time vehicle exits and enters GeoFence (so we don't send repeated alerts) | ||
| // LSEingeofenceandstopped := false |
|
|
||
| // If the distance is outside the radius, that means vehicle is outside the GeoFence. Ok to get out | ||
| if distance > float64(radius) { | ||
| // LSEingeofenceandstopped = false |
|
|
||
| // The following code was removed in order to make loop do the whole test each time, including sending email if disconnected LSE | ||
| // This is to prevent the below logic, if it's already executed, no need to keep doing it | ||
| // LSEif ingeofenceandstopped == true { |
There was a problem hiding this comment.
If within the geofence and disconnected, second+ time through will not send notification with this code in place. I want long check intervals (to prevent battery decline) with a message each time.
| logger.Println(err) | ||
| } | ||
|
|
||
| //LSE // Send text |
There was a problem hiding this comment.
With this code in place, the program writes an error message unless the user has a twilio account. I don't, so the error message (at least) has to be skipped.
| return nil | ||
| } | ||
| package NotifyLib | ||
| // Add second to address. Most mail servers require a FROM: address. This was added to the message by Lee Elson on 6/29/20 |
| to := []string{toAddress} | ||
| msg := []byte("To: " + toAddress + "\r\nSubject: " + subj + "\r\n\r\n" + body + "\r\n") | ||
| serverPort := mailServer + ":" + strconv.Itoa(mailServerPort) | ||
| logger.Printf("Sending mail via server %s\n", serverPort) |
No description provided.