Last post Dec 01, 2014 02:34 PM by ayanmesut
Dec 01, 2014 07:01 AM|ayanmesut|LINK
In the _AppStart, I have :
WebMail.SmtpServer = "smtp.gmail.com";
WebMail.EnableSsl = true;
WebMail.SmtpPort = 587;
WebMail.UserName = "ayanmesut";
WebMail.Password = "mypassword";
WebMail.From = "firstname.lastname@example.org";
In the file:
subject: "There is a question!",
I get this error:
System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after
a period of time, or established connection failed because connected host has failed to respond 184.108.40.206:587 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean
connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) --- End of inner exception stack trace --- at System.Net.ServicePoint.GetConnection(PooledStream PooledStream,
Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6) at System.Net.PooledStream.Activate(Object owningObject, Boolean async, GeneralAsyncDelegate asyncCallback) at System.Net.PooledStream.Activate(Object owningObject,
GeneralAsyncDelegate asyncCallback) at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint) at System.Net.Mail.SmtpTransport.GetConnection(ServicePoint
servicePoint) at System.Net.Mail.SmtpClient.GetConnection() at System.Net.Mail.SmtpClient.Send(MailMessage message) --- End of inner exception stack trace --- at System.Net.Mail.SmtpClient.Send(MailMessage message) at System.Web.Helpers.WebMail.Send(String
to, String subject, String body, String from, String cc, IEnumerable`1 filesToAttach, Boolean isBodyHtml, IEnumerable`1 additionalHeaders, String bcc, String contentEncoding, String headerEncoding, String priority, String replyTo) at ASP._Page_ContactUs_cshtml.Execute()
in c:\Users\Mes\Desktop\Web Development With WebMatrix\EmptySiteAsp.net\ContactUs.cshtml:line 26
Dec 01, 2014 07:11 AM|AidyF|LINK
Google "send email using gmail asp.net" as this is probably ask at least once a day. You're probably missing the "UseDefaultCredentials = false" line, but look at some sample code and you'll have an idea what you're missing, and you'll also find solutions
to other issues you're likely to have.
In general though it is a bad idea to send automated email through gmail's smtp servers.
Dec 01, 2014 07:21 AM|ayanmesut|LINK
I added the following code:
WebMail.SmtpUseDefaultCredentials = false;
It does not help. I checked many solutions but I cannot get the result. I am using gmail because I just want to check that. In my real apps, I use hosting smtp service.
Dec 01, 2014 07:56 AM|wavemaster|LINK
make the username field your complete gmail account email address.
I don't have the isbodyhtml: true , but it still sends it as such
Dec 01, 2014 12:30 PM|Gautam Sharma|LINK
user name must be
WebMail.UserName = "email@example.com";
Dec 01, 2014 12:59 PM|ayanmesut|LINK
I still have error:
System.Net.Mail.SmtpException: 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 at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode,
String response) at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte command, MailAddress from, Boolean allowUnicode) at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, Boolean
allowUnicode, SmtpFailedRecipientException& exception) at System.Net.Mail.SmtpClient.Send(MailMessage message) at System.Web.Helpers.WebMail.Send(String to, String subject, String body, String from, String cc, IEnumerable`1 filesToAttach, Boolean isBodyHtml,
IEnumerable`1 additionalHeaders, String bcc, String contentEncoding, String headerEncoding, String priority, String replyTo) at ASP._Page_ContactUs_cshtml.Execute() in c:\Users\Mes\Desktop\Web Development With WebMatrix\EmptySiteAsp.net\ContactUs.cshtml:line
Dec 01, 2014 01:10 PM|Gautam Sharma|LINK
1) either your password is wrong
2) check your gmail settings. Have you enabled the send email from applications options? Go to settings > forwarding and pop/imap and enable imap
Dec 01, 2014 02:34 PM|ayanmesut|LINK
thanx for your help.
I also did the following:
go to security.google.com/settings/security/activity and here you'll see blocked connection from your code. Allow them.