This has been getting on my nerves quite a bit because I can't find a reason for this not to work. I have an mvcMailer code that works if I specify in web.config to use SMTP. I don't want to use SMTP though, I want to use the drop folder. This is part of the code that does the sending:
[HttpPost]
public ActionResult Edit(Deviation deviation, int[] Epost)
{
if (ModelState.IsValid)
{
db.Entry(deviation).State = EntityState.Modified;
db.SaveChanges();
if (Epost != null)
{
var myEpost = from p in db.Users
where Epost.Contains(p.UserID)
select p;
myEpost.ToList();
var subject = deviation.Benamning;
var body = deviation.KortBeskrivning;
var avId = deviation.DeviationId;
foreach (var item in myEpost)
{
var mailer = new UserMailer();
var msg = mailer.DeviationMessage(email: item.Epost, body: body, subject: subject, name: item.Name, avId: avId);
msg.Send();
}
}
return RedirectToAction("Index");
//return RedirectToAction("Index");
}
return View(deviation);
}
This code works if the web.config file is configured like this:
<smtp from="user@domain.com">
<network enableSsl="false" host="192.168.111.11" port="25" userName="user@domain.com" password="password" />
</smtp>
But neither of these alternatives work, they all give the same error (SMTP host not specified):
<smtp deliveryMethod="SpecifiedPickupDirectory">
<specifiedPickupDirectory pickupDirectoryLocation="C:\inetpub\mailroot\pickup"/>
</smtp>
<smtp from="user@domain.com" deliveryMethod="SpecifiedPickupDirectory">
<specifiedPickupDirectory pickupDirectoryLocation="C:\inetpub\mailroot\pickup"/>
</smtp>
It's worth noting I guess, that a file is created in the drop folder anyway, despite the error. I just don't know what's wrong, based on what I've been able to find on mvcmailer this is the correct configuration to use.
Try something like below. The below one always work for me:
<smtp from="some-email@gmail.com" deliveryMethod="SpecifiedPickupDirectory">
<network host="localhost" />
<specifiedPickupDirectory pickupDirectoryLocation="c:\temp\"/>
</smtp>