Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending mail using goamil v2 -Taking loo long and no response #204

Open
ganeshsaptang opened this issue Jan 7, 2025 · 4 comments
Open

Comments

@ganeshsaptang
Copy link

ganeshsaptang commented Jan 7, 2025

How to send mails using gomail v2 with STARTTLS ? but without credentials {username and password } is it possible? I tried without using username password but its taking loo long and no response.

This is the config im passing to my Dialandsend method :
tlsConfig := &tls.Config{InsecureSkipVerify: true, ServerName: hostName}
dialer := gomail.Dialer{
Host: hostName,{smtp-relay.gmail.com }
Port: portNumInt,
TLSConfig: tlsConfig,
}

I tried with port 25 and it worked fine but for startTLS its not working and the functionality is working fine in python(using smtplib) any ideas ? 
@wneessen
Copy link

wneessen commented Jan 9, 2025

Hi,

gomail.v2 should automatically perform STARTTLS if the server it connects to announces the STARTTLS extension. Authentication should be skipped if the username and password fields are empty when calling NewDialer()

That being said, this package is not actively maintained anymore (the original maintainer of the project unfortunately passed away in 2016: #182). You might wanna look for an alternative like https://github.com/wneessen/go-mail. wneessen/go-mail has dedicated configuration parameters for forced STARTTLS as well as no authentication.

@ganeshsaptang
Copy link
Author

ganeshsaptang commented Jan 22, 2025

hello @wneessen i have an issue with sending mails to gmail with attachments. im sending the attachment content as bytes cause the gmail expects without base 64 encoded but the recipient recieves messages like this

--2485178b365e8156377801e519597459c8657ff2c5304ae68093127df1af
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8

This is a test email with an attachment sent using Golang via SMTP Relay.
--2485178b365e8156377801e519597459c8657ff2c5304ae68093127df1af
Content-Disposition: attachment; filename="testdoc.txt.txt"
Content-Transfer-Encoding: base64
Content-Type: application/octet-stream; name="testdoc.txt.txt"

VGhpcyBpcyB0ZXN0IGRvY3VtZW50
--2485178b365e8156377801e519597459c8657ff2c5304ae68093127df1af--

this is my code :

		msg.Attach(attachment.Name, gomail.SetCopyFunc(func(w io.Writer) error {
			_, err := w.Write(attachment.Content)  // in this the content is byte  (im using gomail struct to populate data )
		}),
			gomail.SetHeader(map[string][]string{
				"Content-Type": {attachment.ContentType},
				// "Content-Transfer-Encoding": {"binary"}, 
				// "Content-Disposition": {fmt.Sprintf("attachment; filename=\"%s\"", attachment.Name)},
			}),
		)

i tried exclusively setting up header as binary but doesnt worked and also tried lot ways. please help me out to solve this thanks in advance

@wneessen
Copy link

Hi @ganeshsaptang,

I haven't looked into the details of this package for years and I don't have the resources to dive into it - and as said it's not maintained anymore. So I won't be able to help you here at this point. I suggest you try out https://github.com/wneessen/go-mail. It has proper attachment handling included and is actively maintained. If you run into issues with that, please open a issue in the project accordingly.

@ganeshsaptang
Copy link
Author

Thanks @wneessen for your reply! sure i will use your package for development.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants