I’ve just written a piece of code for a MVC website that sends a SMTP email using the .NET SmtpClient via our Exchange server. The email it sends has a HTML body with links to images and a file that are hosted on the website.
The email is sent fine when run internally on our network, but when its run from the hosted server that’s not on our domin, the email comes through but the body is blank. Does anybody have any idea why? Is is because of the linked images or file that could be a potential threat and come from a server not on the domain and so is not trusted?
Here’s the code that sends the email, it uses the MailDefinition class to insert a link to a file into the body that they’ve requested to download:
MailDefinition md = new MailDefinition();
md.From = "test@testing.com";
md.Subject = "Test Email";
md.IsBodyHtml = true;
ListDictionary replacements = new ListDictionary();
replacements.Add("REQUESTED_LINK", @"C:\MyFile.pdf");
MailMessage email = md.CreateMailMessage(mailTo, replacements, content, new System.Web.UI.Control());
SmtpClient emailClient = new SmtpClient();
emailClient.Host = "MyExchangeServer";
emailClient.Send(email);
Fixed, turns out the .html file containing the body of the email hadn’t been deployed to the live server, and so the body of the email was blank as a result. Adding it fixed the problem, so it turns out it wasn’t a security issue after all. Thanks for your help