I’m having trouble using smtp. I’m a novice user and tried modifying the code in the documentation:
package main
import (
“log”
“net/smtp”
)
// variables to make ExamplePlainAuth compile, without adding
// unnecessary noise there.
var (
from = “MYEMAIL_at_charter.net”
msg = []byte(“dummy message”)
recipients = []string{“MY_EMAIL_at_gmail.com”}
)
func main() {
// hostname is used by PlainAuth to validate the TLS certificate.
hostname := “mobile.charter.net”
auth := smtp.PlainAuth("", “MYEMAIL_at_charter.net”, “MY_CHARTER_PASSWD”, hostname)
c := make(chan os.Signal)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() {
<-c
pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)
os.Exit(0) // Is just there so that CTRL+C still quits the program.
}()
would allow you to hit CTRL+C and see where it blocks.
Not sure what to make of this but I suppose I could look at the smtp.go file. I was hoping someone had used this example to send an email and could offer advice on input parameters that work.
I have no network experience, but I guess it should be possible to printf debug or use wireshark to see why the smtp.SendMail wants to read more from the server than it gets. Or use (via exec.Command) a smtp client that supports a timeout, or change the mail service, or - if your mail actually gets sent - put the blocking thing into a goroutine and ignore that it’s not working perfectly.
Tried it myself, for me Gmail worked with port 25. But only after I had set IMAP to on in Gmail account settings in the POP/IMAP tab and after using Thunderbird with the server settings.
was this fixed? in troubleshooting any mail sending app, one needs to isolate where the problem come from. chief among them is the OS… try sending mail first from the OS and see what happens. don’t forget to include the error message/s if any.
Made the change from port 465 to port 25 and it worked using gmail! Thanks for the tip. I also have the secure app only turned off. Works with Charter too