Git Product home page Git Product logo

Comments (6)

mhale avatar mhale commented on August 20, 2024 1

It seems like you've understood correctly. Does it work if you try to send email locally, to rule out the network being a problem? Here is some example code to test it.

package main

import (
	"log"
	"net/smtp"
)

func main() {
	err := smtp.SendMail(
		"localhost:25",
		nil,
		"[email protected]",
		[]string{"[email protected]"},
		[]byte(
			"From: Foo Bar <[email protected]>\r\n"+
			"Content-Type: text/plain; charset=us-ascii\r\n"+
			"Content-Transfer-Encoding: 7bit\r\n"+
			"Subject: Test mail\r\n"+
			"Date: Tue, 11 Mar 2014 11:14:26 +0800\r\n"+
			"To: Baz Quux <[email protected]>\r\n\r\n"+
			"This is the first line.\r\n"+
			".This line should not have a leading period.\r\n"+
			"This is the third line."),
	)
	if err != nil {
		log.Fatal(err)
	}
}

from smtpd.

mhale avatar mhale commented on August 20, 2024 1

An outgoing SMTP server (e.g. what you configure in Outlook) and an incoming SMTP server are essentially the same thing - they are servers that receive email with the SMTP protocol.

What you're describing is what this library was designed to do, as a component of the Mailrouter project. So yes, it is possible.

The problem is there is more spam than genuine email, and the internet is like the wild west, so there are many schemes that interfere with email flow such as spam filters and ISPs that block port 25. The sample code above, if run on the same host as your server, would help you test your implementation by ruling out the network as the problem.

In your shoes, I would first ensure my code is doing what I wanted it to do by sending mail to it on the same host. If that works, try it from your local machine.

from smtpd.

mhale avatar mhale commented on August 20, 2024 1

It may help your debugging to enable debug mode (smtpd.Debug = true). The library will log what it is reading and writing on the socket by default, but you can override that with your own functions (see LogRead and LogWrite in the library code).

If you find that systems on the internet can connect to your service fine but you still can't get mail through, there might be a bug in the library. If so, please enable debug mode and create an issue for it here with the log output attached so I can look at it. I may be able to create a test case from the log output, and fix the bug.

from smtpd.

sf-steve avatar sf-steve commented on August 20, 2024

Thanks for responding so quickly.
No I haven't tried that, but looking at that code makes me worry I have misunderstood what this library does.
It looks very much like it's designed for mail clients to connect to, eg I would put gomail.fl9.uk into the outgoing mail server settings for outlook / thunderbird.
What I was attempting to do was capture any email sent TO [email protected] from anyone else, without them having to specifically configure their email client.

Is this possible with this library, or have I got everything back to front?

from smtpd.

sf-steve avatar sf-steve commented on August 20, 2024

Thankyou that's really helpful. Not understanding the fundamental aspects like this has left me feeling quite lost, since I didn't even know what to Google.
Now I know I'm on the right track at least.
Being able to test locally will also make debugging much easier.

from smtpd.

sf-steve avatar sf-steve commented on August 20, 2024

Great, thankyou.
The issue is almost certainly something I'm doing, but if I do find a genuine bug, I'll post a new issue with full details.
I'll close this now since my question has been answered.

Thanks again

from smtpd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.