CF.NET SMTP - Send Email Using Gmail

I am trying to send an email from my application. I can send an email to smtp.mail.yahoo.com, however, while I try to send an email from gmail (smtp.gmail.com), it fails.

I am using SocketPro.

I am trying to use openSSL, but I do not know how to use it!

Does anyone have a sample code that you can provide me with for sending emails 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: < aaa@gmail.com >")); m_ClientSocket.Send(Encoding.UTF8.GetBytes("\r\n")); m_ClientSocket.Send(Encoding.UTF8.GetBytes("RCPT TO: < bbbbb@gmail.com >")); 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: < aaa@gmail.com >")); m_ClientSocket.Send(Encoding.UTF8.GetBytes("To: < bbbbb@gmail.com >")); 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")); 

Could you help me?

Thanks.

Andrew

+4
source share
2 answers

I do not know if this helps, but GMail SMTP servers require the use of SSL on port 465.

Source: http://mail.google.com/support/bin/answer.py?answer=76147

+1
source

Why not use the .Net Smtp client? (In the System.Net.Mail namespace)

  SmtpClient client = new SmtpClient(); client.Credentials = new System.Net.NetworkCredential("username", "password"); client.Host = "some.smtpserver.com"; client.Send(from, to, subject, body); 
+1
source

Source: https://habr.com/ru/post/1315675/


All Articles