Solvedhow to send a string to my gmail?

Posts 1–10 of 10 · Page 1 of 1
how to send a string to my gmail?
as the title says, i wrote a program that stores whats inside a text file in a string and im trying to send whats stored in the string to my gmail or even a private host. ive this using windows form application, however i dont care if its through windows form or console. i get this error when i click the button

An unhandled exception of type 'System.Net.Mail.SmtpException' occurred in System.dll

Additional information: 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
Code:
MailMessage^ mail = gcnew MailMessage("mygmail@gmail.com", "mygmail@gmail.com", "subject test", "body test, i want my string here");
SmtpClient^ client = gcnew SmtpClient("smtp.gmail.com");
client->Port = 587;
client->Credentials = gcnew System::Net::NetworkCredential();
client->EnableSsl = true;
client->Send(mail);
In your
Code:
NetworkCredential();
You need to pass authentication parameters, such as a password/username.
Quote Originally Posted by Coridex73 View Post
In your
Code:
NetworkCredential();
You need to pass authentication parameters, such as a password/username.
oops i posted a version where i crtl Zed alot, i passed those. trying jamesBond's suggestion now

- - - Updated - - -

Quote Originally Posted by Silent View Post
I was mucking around ages ago with something like that, But it was a bug reporting thing. And I'd get errors like you. But I think I know what's wrong.

Code:
Client.Host = "mail.google.com";
Client.EnableSsl = true;
Client.Port = 465;
Client.UseDefaultCredentials = false;
Client.Credentials = new NetworkCredential("email", "password");
I believe your error is something to do with the port and ssl. If you look at this, It says port 587 uses TLS authentication, and 465 uses SSL. So try the code above, or change your port. Although I thought SSL and TLS where practically the same thing. Anyway, Try that and post back your results :P
changed the port to 465 and it took alot longer to throw an error
Code:
An unhandled exception of type 'System.Net.Mail.SmtpException' occurred in System.dll

Additional information: Failure sending mail.
would it be easier to send it to a webhost such as 000webhost as an example? ill explain my goal and that might help a bit. remember the old dayz key stealers? im pretty much doing that except im not taking keys or messing around in the registry or anything like that but the concept is the same, take whats in a txt file and send it to either a gmail or webserver
Quote Originally Posted by gogogokitty View Post
oops i posted a version where i crtl Zed alot, i passed those. trying jamesBond's suggestion now

- - - Updated - - -



changed the port to 465 and it took alot longer to throw an error
Code:
An unhandled exception of type 'System.Net.Mail.SmtpException' occurred in System.dll

Additional information: Failure sending mail.
would it be easier to send it to a webhost such as 000webhost as an example?
Gmail should work fine. There really wouldn't be a difference. Disable SSL and see where that leads.

Code:
client->EnableSsl = false;
Quote Originally Posted by Coridex73 View Post


Gmail should work fine. There really wouldn't be a difference. Disable SSL and see where that leads.
Make sure to use port 21 though.
Quote Originally Posted by Silent View Post


Make sure to use port 21 though.
same error
Code:
MailMessage^ mail = gcnew MailMessage(textBox_FROM->Text, textBox_TO->Text, textBox_SUBJECT->Text, textBox_BODY->Text);
		SmtpClient^ client = gcnew SmtpClient(textBox_SMTP->Text);
		client->Port = 21;
		client->Credentials = gcnew System::Net::NetworkCredential(textBox_USERNAME->Text, textBox_PASSWORD->Text);
		client->EnableSsl = false;
		client->Send(mail);
Quote Originally Posted by gogogokitty View Post
same error
Code:
MailMessage^ mail = gcnew MailMessage(textBox_FROM->Text, textBox_TO->Text, textBox_SUBJECT->Text, textBox_BODY->Text);
		SmtpClient^ client = gcnew SmtpClient(textBox_SMTP->Text);
		client->Port = 21;
		client->Credentials = gcnew System::Net::NetworkCredential(textBox_USERNAME->Text, textBox_PASSWORD->Text);
		client->EnableSsl = false;
		client->Send(mail);
tbh, It's prob something to do with google, I've tried using SMTP with google before and it'd just give me errors. Maybe try another email client?
Quote Originally Posted by Silent View Post


tbh, It's prob something to do with google, I've tried using SMTP with google before and it'd just give me errors. Maybe try another email client?
ive done some research previously to try that and was not able to come up with a decent email that didnt use ssl/tls authentication that i had access to unless im just blind.
Quote Originally Posted by Coridex73 View Post


Gmail should work fine. There really wouldn't be a difference. Disable SSL and see where that leads.

Code:
client->EnableSsl = false;
first question, what the heck did you do to get banned since last night?

second question is, i asked on another forum and a reply stated this,
Your code looks fine and works perfectly on my machine.
Since many things can go wrong I would wrap the code in a try catch block.

however im unsure whats causing the error. any idea if there could be a google settings preventing anything from coming from a unknown source?

edit: Solved
I was mucking around ages ago with something like that, But it was a bug reporting thing. And I'd get errors like you. But I think I know what's wrong.

Code:
Client.Host = "mail.google.com";
Client.EnableSsl = true;
Client.Port = 465;
Client.UseDefaultCredentials = false;
Client.Credentials = new NetworkCredential("email", "password");
I believe your error is something to do with the port and ssl. If you look at this, It says port 587 uses TLS authentication, and 465 uses SSL. So try the code above, or change your port. Although I thought SSL and TLS where practically the same thing. Anyway, Try that and post back your results :P
Posts 1–10 of 10 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Talk with us