last day (15 days later) » 

8:36 PM
0
A: "The SMTP host was not specified." - but it is specified?

TommyIn a clean MVC project, I am unable to replicate your issue. Following the ScottGu blog post here, I was able to get a gmail sent email without issue (VS 2013, .NET 4.5.1, MVC 5). Note the the <system.web> element is a top level element and not nested inside of AppSettings or <system.web> Web....

 
Hello, I am actually able to send emails, however I have to specify the attributes (such as port, enableSsl) inside the controller. The Web.Config file doesn't seem to have any effect at all. When I change new SmtpClient(); to new SmtpClient("smtp.gmail.com");, I actually receive a different error - "A from address must be specified", which makes me think the Web.Config file isn't even being recognised?
 
@user2945993 - thats what I am saying though. I can set this up in the web.config and it works without issue. Can you try the code I posted above in a new/clean project? Do you still have the issues?
@user2945993 Are you 100% that these values are not being overwritten by a web.config transformation? Are you debugging locally or publishing to a server?
 
I'm unsure if they're being overridden - just testing a new project now and will let you know.
 
@user2945993 - good deal. Literally copy the code I have above and replace the necessary values. Also, the <system.net> is a top level web.configuration element. Ensure you don't have it buried under some other element (like inside system.web or appSettings)
 
It works 100% fine in a new project. You're right, I'm going to have to look at what could be overriding this.
 
8:36 PM
@user2945993 Good deal. Double check your configuration settings, make sure you don't have a funny typo, elements in wrong position inside the configuration file and that the compiler isn't transforming and erasing your settings. Beyond that, I am not sure I can help much more at this point :/
 
Thanks. Would seeing my config file help? I could chuck it in a pastebin quick.
 
@user2945993 - sure, just be sure to scrub PWDs out of there first :)
 
Here you go - pastebin.com/mnd4Hgba - thanks for checking it out!
 
...this looks like the web.config from your Views folder and not the web.config at the root of the application
 
Oh my, I think I've completely embarrassed myself here! Really sorry for this
 
8:39 PM
Its ok man, its why we are here! Yup, that setting needs to go into the root web.config :)
 
Great, thanks a lot! I'll mark the answer as accepted, and have a great day :)
 
I will edit my answer to ensure anyone else that comes across this knows which web.config to edit :)
 
Good idea haha :D
Again, thanks a lot, bye!
 

last day (15 days later) »