smtp send mail not sending anything - asp.net

I am trying to update the credentials that are being used for sending emails.
I am updating to use office 365. Here is what i have set in my config file. No email is being sent.
<smtp from="registrar#mysite.com">
<network password="mypassword" userName="user#mysite.com" host="mail.mysite.com"
targetName="STARTTLS/smtp.office365.com" port="587" enableSsl="true" />
</smtp>

Related

MvcMailer not working on production

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

Can I set ntlm authentication for a mail server via the web.config file?

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

multiple SMTP details used in Web.Config in ASP.NET [duplicate]

This question already has answers here:
Setting multiple SMTP settings in web.config?
(8 answers)
Closed 8 years ago.
I have to used Multiple smtp detail in web.config file, may I used like this and how i can access different smtp for different purposes. I want to used first smtp for logging error. and second for successful mail to users.
Example
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="test#gmail.com">
<network defaultCredentials="false" host="smtp.gmail.com" port="587" userName="test#gmail.com" password="test"/>
</smtp>
<smtp deliveryMethod="Network" from="tes2t#gmail.com">
<network defaultCredentials="false" host="smtp.gmail.com" port="587" userName="tes2t#gmail.com" password="test2"/>
</smtp>
</mailSettings>
How i can use first smtp for logging and second smtp for success msgs.
You must define multiple section based on System.Net.Configuration.SmtpSection type.
Your answer is here

I need to send an Email notification in my exception message using asp.net MVC

I need to send and Email when Any Message occurs I am trying to logg the errors once I logged it I need to send the Email to them..
Thanks
A compbination of ELMAH and System.Net.Mail...
ELMAH:
http://code.google.com/p/elmah/
System.Net.Mail Namespace:
http://msdn.microsoft.com/en-us/library/system.net.mail.aspx
In Code:
using System.Net.Mail;
// ...
SmtpClient mailClient = new SmtpClient();
mailClient.Send(from, to, subject, body);
In Web.Config:
<system.net>
<mailSettings>
<smtp from=your_email#gmail.com>
<network host="smtp.gmail.com"
password="your_pwd"
port="587"
userName="your_username#gmail.com"/>
</smtp>
</mailSettings>
</system.net>
You can use log4net as your infrastructure of logging and in the config add an email appender (EventLogAppender).

How do you configure Password Recovery control in ASP.Net?

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>

Resources