Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure SMTP settings in web.config

I'm trying to fix an email issue with an inherited website and don't have access to the code (i.e. just the compiled files). This site needs to be hosted on a new web server having a different SMTP server.

Upon decompiling bits of the code I can see emails are sent using method like below in code snippet and SMTP is set as smtpMail.SmtpServer="localhost" but my new webserver's SMTP server is "relay.tagadab.com" how can we possibly configure this in web.config so that localhost is taken as "relay.tagadab.com"

Imports Microsoft.VisualBasic, System.Web.Mail  Shared Sub SendMail(ByVal ToAdd, ByVal FromAdd, ByVal Message, ByVal Subject)      Dim msgMail As New MailMessage()      msgMail.To = ToAdd     msgMail.From = FromAdd     msgMail.Subject = Subject     msgMail.Headers.Add("X-Mailer", "ASP.NET")      msgMail.BodyFormat = MailFormat.Text     msgMail.Body = Message     'SmtpMail.SmtpServer = "mail.the-radiator.com"     SmtpMail.SmtpServer = "localhost"     SmtpMail.Send(msgMail)  End Sub 

I added this section in my web.config but that does not make a difference

<system.net>     <mailSettings>         <smtp>             <network host="relay.tagadab.com" port="25" />         </smtp>      </mailSettings> </system.net> 
like image 978
rumi Avatar asked Oct 07 '13 19:10

rumi


People also ask

How do I find my SMTP settings?

Outlook for PCIn Outlook, click File. Then navigate to Account Settings > Account Settings. On the Email tab, double-click on the account you want to connect to HubSpot. Below Server Information, you can find your incoming mail server (IMAP) and outgoing mail server (SMTP) names.


1 Answers

Web.Config file:

<configuration>  <system.net>         <mailSettings>             <smtp from="[email protected]">                 <network host="smtp.gmail.com"                   port="587"                   userName="[email protected]"                   password="yourpassword"                   enableSsl="true"/>             </smtp>         </mailSettings> </system.net> </configuration> 
like image 58
Sanjay kumar Avatar answered Sep 24 '22 00:09

Sanjay kumar