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:
这让我很紧张,因为我找不到不工作的原因。我有一个mvcMailer代码,如果我在web中指定,它可以工作。配置使用SMTP。我不想使用SMTP,我想使用drop文件夹。这是发送代码的一部分:
[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:
这个代码在web上工作。配置文件配置如下:
<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主机未指定):
<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.
值得注意的是,尽管有错误,仍然在drop文件夹中创建了一个文件。我不知道哪里出错了,根据我在mvcmailer上找到的,这是正确的配置。
1 个解决方案
#1
1
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>
#1
1
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>