But i am get error when i do the transaction with smtp :
errors like that :
The server rejected the sender address. The server response was: 530 5.7.0 Must issue a STARTTLS command first. n35sm3933492wfa.15
i am using gmail to test this application.
Please give me suggestion , how to correct it ?
thanks in advances.
7 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Dear krishna prasad.
many thanks to you.
To base your code , i am get the error like that : The SMTP server requires a secure connection or the client was not authenticated. the server response was: 5.5.1 Authentication required
and i also change port that it is
smtp.Port = 465;
still get error : request time out :
Please check your network credentials...the user name and password (i.e "metilmarket";
"i5kngyvx";
) is incorrect..Try a give a valid gmail id and password...which u use...
System.Net.NetworkCredential("[email protected]", "babilona"); and replace here....
And also...have a text file called something.txt in c: ........cause i have added it in my code...
message.Attachments.Add(new Attachment("c:\\something.txt")); as an attachment...
Later u can modify as per ur requirements...
Hope i made myself clear....Feel free to ask any doubts...
Dear.
are there another solution to send mail if i am don't use the library( System.Net.Mail;) and replace to (System.Web)?
because my server is using visual studio 2003 that it is has trouble according to sending mail.
thanks
Please check your network credentials...the user name and password (i.e "metilmarket";
"i5kngyvx";
) is incorrect..Try a give a valid gmail id and password...which u use...
System.Net.NetworkCredential("[email protected]", "babilona"); and replace here....
And also...have a text file called something.txt in c: ........cause i have added it in my code...
message.Attachments.Add(new Attachment("c:\\something.txt")); as an attachment...
Later u can modify as per ur requirements...
Hope i made myself clear....Feel free to ask any doubts...
Thanks you .
it is run well now (the error on incorrect password), i am test it run on framwork 3.5 , but when i am test it on framework 1.1 , it is not include the library System.Net.Mail.
it just have system.Web.mail.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- If my answer helped you........Don't forget to mark it as correct answer....
Former memberPosted Sep 16, 2010, 8:30 PM EDT
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Net.Mail;
namespace consolemail
{
class Program
{
static void Main(string[] args)
{
MailMessage message = new MailMessage();
SmtpClient smtp = new SmtpClient();
System.Net.NetworkCredential AuthInfo = new
System.Net.NetworkCredential("[email protected]", "babilona");
message.To.Add("[email protected]");
message.Subject = "Test Mail using System.Net.Mail";
message.From = new MailAddress("[email protected]");
string str = "Hai to all";
message.Body = str;
bool isBodyHtml = true;
message.IsBodyHtml = isBodyHtml;
message.Attachments.Add(new Attachment("c:\\something.txt"));
message.SubjectEncoding = System.Text.Encoding.UTF8;
message.BodyEncoding = System.Text.Encoding.UTF8;
message.Priority = MailPriority.High;
smtp.Host = "smtp.gmail.com";
smtp.UseDefaultCredentials = false;
smtp.Credentials = AuthInfo;
smtp.Timeout = 20000;
smtp.Port = 587;
// use stmp.port = 587 if 465 does not work.
smtp.EnableSsl = true;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
try
{
smtp.Send(message);
Console.WriteLine("E-mail has been sent succesfully");
Console.ReadLine();
}
catch (System.Net.Mail.SmtpException ex)
{
Console.WriteLine(ex.Message);
Console.ReadLine();
}
}
}
}
Hai use this peice of code..Hope it helps u...
If My Answer Helped u don't forget to mark it .....
benzema kirism18 pointsPosted Sep 16, 2010, 10:09 PM EDT
many thanks to you.
To base your code , i am get the error like that :
The SMTP server requires a secure connection or the client was not authenticated. the server response was: 5.5.1 Authentication required
and i also change port that it is
smtp.Port = 465;
still get error : request time out :
thanks and best regards.
Former memberPosted Sep 16, 2010, 10:22 PM EDT
Please check your network credentials...the user name and password (i.e "metilmarket";
"i5kngyvx";) is incorrect..Try a give a valid gmail id and password...which u use...System.Net.NetworkCredential("[email protected]", "babilona"); and replace here....
And also...have a text file called something.txt in c: ........cause i have added it in my code...
message.Attachments.Add(new Attachment("c:\\something.txt")); as an attachment...
Later u can modify as per ur requirements...
Hope i made myself clear....Feel free to ask any doubts...
benzema kirism18 pointsPosted Sep 16, 2010, 10:27 PM EDT
are there another solution to send mail if i am don't use the library( System.Net.Mail;) and replace to (System.Web)?
because my server is using visual studio 2003 that it is has trouble according to sending mail.
thanks
Former memberPosted Sep 16, 2010, 10:30 PM EDT
Please check your network credentials...the user name and password (i.e "metilmarket";
"i5kngyvx";) is incorrect..Try a give a valid gmail id and password...which u use...System.Net.NetworkCredential("[email protected]", "babilona"); and replace here....
And also...have a text file called something.txt in c: ........cause i have added it in my code...
message.Attachments.Add(new Attachment("c:\\something.txt")); as an attachment...
Later u can modify as per ur requirements...
Hope i made myself clear....Feel free to ask any doubts...
benzema kirism18 pointsPosted Sep 16, 2010, 10:35 PM EDT
it is run well now (the error on incorrect password), i am test it run on framwork 3.5 , but when i am test it on framework 1.1 , it is not include the library System.Net.Mail.
it just have system.Web.mail.
thanks
Former memberPosted Sep 16, 2010, 11:15 PM EDT
yes u have to have the latest framework......
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
If my answer helped you........Don't forget to mark it as correct answer....