-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue when the connection was remotely closed
- Loading branch information
Showing
3 changed files
with
76 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package smtp | ||
|
||
import ( | ||
"GoMapEnum/src/utils" | ||
|
||
smtp "github.com/nodauf/net-smtp" | ||
) | ||
|
||
func (options *Options) prepareOneConnection(client *smtp.Client) error { | ||
|
||
mailFrom := utils.RandomString(6) + "@" + options.Domain | ||
err := client.Mail(mailFrom) | ||
if err != nil { | ||
//options.Log.Error("Mail From command failed with email: " + mailFrom + " and error " + err.Error()) | ||
return err | ||
} | ||
options.Log.Debug("One connection has been successfully prepared") | ||
|
||
return nil | ||
} | ||
|
||
func (options *Options) createNewConnection() *smtp.Client { | ||
client, err := smtp.Dial(options.Target + ":25") | ||
if err != nil { | ||
options.Log.Error("Failed to establish a connection " + err.Error()) | ||
return nil | ||
} | ||
|
||
hello := utils.RandomString(6) | ||
err = client.Hello(hello) | ||
if err != nil { | ||
options.Log.Error("helo command failed with helo " + hello + " and error " + err.Error()) | ||
return nil | ||
} | ||
return client | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters