<p>Most solutions I found on the web are using gmail with plain passwords in the code, which is quite unpleasant. Gmail doesn't even seem to allow that any longer. </p>
<hr/>**评论:**<br/><br/>anoland: <pre><p><a href="https://github.com/golang/go/wiki/SendingMail" rel="nofollow">https://github.com/golang/go/wiki/SendingMail</a></p>
<p><a href="https://gist.github.com/chrisgillis/10888032" rel="nofollow">https://gist.github.com/chrisgillis/10888032</a></p></pre>Injunire: <pre><p>Just use the net/smtp package to send the email. Then you can use your local system or any other mail servers for outbound mail.</p></pre>TheMerovius: <pre><p>"Without external services" is literally impossible. The Recipients mail server needs to get the E-Mail, so you need to <em>somehow</em> talk SMTP to a mail server on the internet. That mail server also needs to accept the E-Mail, which it won't do, if you don't authenticate. So, either you talk SMTP to an external mail server with some authentication, or you talk to the local mail system which then talks SMTP to an external mail server with some authentication. But your local mail system can't do any magical things that you can't do yourself.</p>
<p>Note, that plain-text authentication isn't a huge problem, if you use service-accounts or service-specific passwords.</p></pre>1Gijs: <pre><p>I use gmail to send emails in some projects and it still works - checked it yesterday.</p>
<p>You could use a sysvar to hold the actual values so those are kept out of the code. You should never ever put credentials in (public) gits.</p></pre>Kindlychung: <pre><p>Could you post a gist? Thanks!</p></pre>lovetocode: <pre><p>The problem is two fold. How do I interface with a mail server using Go? How do I setup, maintain and secure my own mail server? I think you need to figure out the latter first then worry about interfacing with Go. Just my 2 cents</p></pre>sethammons: <pre><p>Why the requirement for no external services? I use <a href="https://github.com/sendgrid/sendgrid-go" rel="nofollow">https://github.com/sendgrid/sendgrid-go</a> (disclaimer, I work with SendGrid). </p>
<p>You could also look into <a href="https://golang.org/pkg/net/smtp/" rel="nofollow">https://golang.org/pkg/net/smtp/</a></p></pre>dhdfdh: <pre><p>I think it's cause he doesn't want to use an external service.</p></pre>
How can I send emails from the local machine in golang without using external services?
agolangf · · 538 次点击这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传