CF.NET SMTP - 使用 Gmail 发送电子邮件
我正在尝试从我的应用程序发送电子邮件。 我可以通过 smtp.mail.yahoo.com 发送电子邮件,但是当我尝试使用 gmail (smtp.gmail.com) 发送电子邮件时,它失败了。
我正在使用 SocketPro。
我也尝试过使用 openSSL 但我不知道如何使用它!
任何人,您有任何代码示例,可以提供给我,从 Gmail 发送电子邮件吗?
我有以下问题:
USocketClass m_ClientSocket;
m_ClientSocket.Send(Encoding.UTF8.GetBytes("EHLO smtp.gmail.com \r\n"));
m_ClientSocket.Send(Encoding.UTF8.GetBytes("AUTH LOGIN"));
m_ClientSocket.Send(Encoding.UTF8.GetBytes("\r\n"));
m_ClientSocket.Send(Encoding.UTF8.GetBytes(EncodeTo64(myUser)));
m_ClientSocket.Send(Encoding.UTF8.GetBytes("\r\n"));
m_ClientSocket.Send(Encoding.UTF8.GetBytes(EncodeTo64(myPass)));
m_ClientSocket.Send(Encoding.UTF8.GetBytes("\r\n"));
m_ClientSocket.Send(Encoding.UTF8.GetBytes("MAIL FROM: <[email protected]>"));
m_ClientSocket.Send(Encoding.UTF8.GetBytes("\r\n"));
m_ClientSocket.Send(Encoding.UTF8.GetBytes("RCPT TO: <[email protected]>"));
m_ClientSocket.Send(Encoding.UTF8.GetBytes("\r\n"));
m_ClientSocket.Send(Encoding.UTF8.GetBytes("DATA"));
m_ClientSocket.Send(Encoding.UTF8.GetBytes("\r\n"));
m_ClientSocket.Send(Encoding.UTF8.GetBytes("From: <[email protected]>"));
m_ClientSocket.Send(Encoding.UTF8.GetBytes("To: <[email protected]>"));
m_ClientSocket.Send(Encoding.UTF8.GetBytes("Subject: Test subject"));
m_ClientSocket.Send(Encoding.UTF8.GetBytes("My body test"));
m_ClientSocket.Send(Encoding.UTF8.GetBytes("."));
m_ClientSocket.Send(Encoding.UTF8.GetBytes("\r\n"));
m_ClientSocket.Send(Encoding.UTF8.GetBytes("QUIT"));
你能帮我吗?
谢谢。
安德鲁
I'm trying to send email from my application.
I can send email by smtp.mail.yahoo.com, however while I'm trying to send the email with gmail (smtp.gmail.com) it fails.
I'm using SocketPro.
I've try to use also openSSL but I don't know how to use it!
Anyone you have any code sample, that you can provide me, to send email from Gmail?
I have the following:
USocketClass m_ClientSocket;
m_ClientSocket.Send(Encoding.UTF8.GetBytes("EHLO smtp.gmail.com \r\n"));
m_ClientSocket.Send(Encoding.UTF8.GetBytes("AUTH LOGIN"));
m_ClientSocket.Send(Encoding.UTF8.GetBytes("\r\n"));
m_ClientSocket.Send(Encoding.UTF8.GetBytes(EncodeTo64(myUser)));
m_ClientSocket.Send(Encoding.UTF8.GetBytes("\r\n"));
m_ClientSocket.Send(Encoding.UTF8.GetBytes(EncodeTo64(myPass)));
m_ClientSocket.Send(Encoding.UTF8.GetBytes("\r\n"));
m_ClientSocket.Send(Encoding.UTF8.GetBytes("MAIL FROM: <[email protected]>"));
m_ClientSocket.Send(Encoding.UTF8.GetBytes("\r\n"));
m_ClientSocket.Send(Encoding.UTF8.GetBytes("RCPT TO: <[email protected]>"));
m_ClientSocket.Send(Encoding.UTF8.GetBytes("\r\n"));
m_ClientSocket.Send(Encoding.UTF8.GetBytes("DATA"));
m_ClientSocket.Send(Encoding.UTF8.GetBytes("\r\n"));
m_ClientSocket.Send(Encoding.UTF8.GetBytes("From: <[email protected]>"));
m_ClientSocket.Send(Encoding.UTF8.GetBytes("To: <[email protected]>"));
m_ClientSocket.Send(Encoding.UTF8.GetBytes("Subject: Test subject"));
m_ClientSocket.Send(Encoding.UTF8.GetBytes("My body test"));
m_ClientSocket.Send(Encoding.UTF8.GetBytes("."));
m_ClientSocket.Send(Encoding.UTF8.GetBytes("\r\n"));
m_ClientSocket.Send(Encoding.UTF8.GetBytes("QUIT"));
can you help me?
Thanks.
Andrew
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道这是否有帮助,但 GMail SMTP 服务器要求您在端口 465 上使用 SSL。
来源:
http://mail.google.com/support/bin/answer.py ?answer=76147
I don't know if this helps, but GMail SMTP servers require you use SSL on port 465.
Source:
http://mail.google.com/support/bin/answer.py?answer=76147
为什么不使用.Net Smtp 客户端? (在 System.Net.Mail 命名空间中)
Why not use the .Net Smtp client? (In the System.Net.Mail namespace)