I had my web.config mail section like that:
<smtp from="mail#gmail.com">
<network enableSsl="true" host="smtp.gmail.com" port="587" userName="mail#gmail.com" password="pwd" />
</smtp>
Tested locally,
but I got an error on production(i am using shared hosting environment):
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.
I googled I find out possible solution,
so I changed my configuration as:
<smtp from="mail#gmail.com">
<network enableSsl="true" host="smtp.gmail.com" port="587" userName="mail#gmail.com" password="pwd" defaultCredentials="true"/>
</smtp>
And now I got this error:
he SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. ko10sm114859924pbd.38 - gsmtp
How can I fix that?
I also tied to add delivery method:
<smtp from="mail#gmail.com" deliveryMethod="Network">
<network enableSsl="true" host="smtp.gmail.com" port="587" userName="mail#gmail.com" password="pwd" defaultCredentials="true"/>
</smtp>
But ho way.
UPDATE
I just checked my gmail and find out email from google
Someone recently used your password to try to sign in to your Google
Account xxxxxxx#gmail.com. This person was using an application such as
an email client or mobile device.
We prevented the sign-in attempt in case this was a hijacker trying to
access your account. Please review the details of the sign-in attempt:
Monday, January xxx.xxx UTC IP Address: xxx.xxx.xxx.xxx Location: Unknown
So may be it is the reason why email send not working on production.
Because it is a new location and when you sign in from a new location on gmail you should answer security questions. So it make scene then why email is not working.
So i am looking now how to unblock that locaton/ip address on gmail if it is possible.
Change this:
<smtp from="mail#gmail.com">
to this:
<smtp from="mail#gmail.com" deliveryMethod="Network">
Edit: I also found this question, hope it helps.
Edit 2: Other solutions:
asp.net The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required
set defaultCredentials="true" to false
Related
Exactly as it says on the tin: is it possible to specify both delivery methods in a single configuration? I'd figure it'd be a quick (and cheap) solution to log all e-mail messages that were sent directly by the standard .NET SmtpClient.
What I'm trying to achieve here is a solution in which every e-mail sent by an defaultly SmtpClient instance is both submitted directly to a configured SMTP server and stored in a pickup directory, which merely will act as a storage point for logging the sent e-mail messages.
In other words: Is a configuration as follows possible?
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="source#domain.com">
<network host="127.0.0.1" />
</smtp>
<smtp deliveryMethod="SpecifiedPickupDirectory">
<specifiedPickupDirectory pickupDirectoryLocation="C:\SmtpLog" />
</smtp>
</mailSettings>
</system.net>
Don't believe this is possible in the manner you suggest - see Scott Gutherie's response on http://weblogs.asp.net/scottgu/archive/2005/12/10/432854.aspx (search page for "multiple SMTP servers"). Old message but still current from what I can tell.
I think the system.net mailSettings in web.config are supposed to be considered the default settings.
However you can do it in code easily enough (plenty of examples out there) and you could do it so that you can configure in web.config using custom settings.
Is it possible to specify that you want to use NTLM authentication for SMTP using system.net, all via the web.config file? If so, what needs to be done?
I've been told adding the following will cause NTLM or Kerberos to be used if the SMTP server requires it, but our SMTP server is not authenticating. (I'm no SMTP expert).
<configuration>
<system.net>
<mailSettings>
<smtp>
<network host="yourhost.com" userName="user#yourhost.com" password="yourpassword" port="yourport" defaultCredentials="true" />
</smtp>
</mailSettings>
</system.net>
E.g. Should there be authentication modules specified?
You may have a look at this blog
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. k12sm3795394wby.16
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. k12sm3795394wby.16
Source Error:
I am using createUserWizard.. it has a mailing option in its properties that i set using the designer (VS2010). When I used code it worked!, but with that control it doesnt. I wonder why!!
Here is my web.config file:
<system.net>
<mailSettings>
<smtp from="makovetskiyd#yahoo.co.uk">
<network host="smtp.gmail.com" defaultCredentials="false"
port="587" userName="**********" password="*****"/>
</smtp>
</mailSettings>
</system.net>
But I doubt the control uses that setting.
Gmail requires you to use a secure connection. This can be set in your web.config like this:
<network host="smtp.gmail.com" enableSsl="true" ... />
Gmail is blocking your SQL Server instance from sending emails through it. Once you encounter your error, if you login to gmail and try to compose a message, it'll notify you of an access that it blocked. You just need to tell Gmail that this was ligitimate and to allow future logins from sqlserver.
This should do the trick!
I'm trying to send email via google apps from my asp.net app and am getting the following exception:
{"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 "}
My Web.config has the following values (sorry I couldn't get the XML to display):
<system.net>
<mailSettings>
<smtp from="user#domain.com"
deliveryMethod="Network">
<network host="smtp.gmail.com"
port="587"
userName="user#domain.com"
password="password"
enableSsl="true"/>
</smtp>
</mailSettings>
</system.net>
I'm thinking that this is due to my not having an SSL cert but I'm not sure. Any thoughts?
I have it working this way with one of our gmail account (code is simplified):
SmtpClient client = new SmtpClient("smtp.gmail.com", "smtp.gmail.com");
client.EnableSsl = true;
client.Credentials = new NetworkCredential(userName, userPassword);
client.Send(mail); // mail is of type System.Net.Mail.MailMessage
You could try to send an email with this code and your configuration just to see if you receive the same error message.
Your code should work fine; I use the exact same configuration successfully.
You may have a firewall issue.
I have a password recovery control that is set up to ask the user their security question. I have configured the from email and subject, but I am receiving a runtime error stating SMTP host is not specified.
Can someone tell me where I need to set the host?
Thanks
Add a system.net section to your web.config with the following:
<system.net>
<mailSettings>
<smtp deliveryMethod="Network">
<network host="yourmailserveraddress"/>
</smtp>
</mailSettings>
</system.net>