Comments (6)
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.
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.
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.
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.
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.
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)
- Add AUTH support HOT 1
- Support for large emails via smart disk buffering? HOT 9
- sending Email HOT 1
- Too many recipients HOT 1
- How can I sign an outgoing email with DKIM? HOT 1
- From and To addresses with leading spaces HOT 3
- Save state after authentication HOT 7
- Adding go.mod and tagging release? HOT 2
- Wrong operator used? HOT 1
- Fix go.mod HOT 3
- How to gracefully shutdown smtpd? HOT 5
- Example not working HOT 3
- On shutdown, smtpd waits for one more message before shutting down
- how to send email? HOT 4
- Possibility to publish a version HOT 2
- how to get the body of the email? HOT 2
- A minimum of 100 Users have to be allowed. so > 100 can be dropped
- tls support HOT 3
- Feature request: Connection Timeout HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from smtpd.