We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Can't send to gmail account (5.4)

Hi there,

I have been trying to figure out how to connect to gmail via SMTP to send myself a message as a test, but it seems that no matter what options I try, I always get a response back similar to this:

The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at
5.5.1 https://support.google.com/mail/answer/14257

I’m using some very simple code, and my understanding based on what I’ve read in the forums is that this is correct:

//Declare message as MailMessage instance
MailMessage message = new MailMessage();

//Here is the sender’s address
message.From = “”; // I use my gmail address

//Here is the recipient’s address
message.To = “”; // I use my gmail address

message.Subject = “Test e-mail”;

//Here is the email message
message.TextBody = “A test email from the Aspose client”;

//Send email using SmtpClient
//Create an instance of the SmtpClient Class
SmtpClient client = new SmtpClient(“smtp.gmail.com”, Aspose.Email.SecurityOptions.SSLExplicit);

//Specify your mail user name
client.Username = “”; // My gmail address

//Specify your mail password
client.Password = “”; // My gmail password

//Specify your Port #
client.Port = 587;

I have tried turning on Authentication, I’ve also tried “GetCapabilities” to make sure it was working (and those return values and acceptable login types). I am out off ideas.

Additionally, the first time I tried this, I received an email from Gmail itself saying that it blocked an attempt to access my mailbox from an insecure device and to use the Gmail app instead. I DID select the option to say it was my device but it doesn’t matter, it still blocks it.


Thank you.


This is a requirement by Gmail service provider for securing access to customer information. We can’t help in this as Google requires this to access the email. After providing access to less secure applications, I was able to access the information from a test Google account which otherwise was not allowing access. You need to complete all the steps on this link: https://support.google.com/mail/answer/14257 and then wait for some time to have access to your account. Please try it at your end and share your feedback with us.