当我想使用拾取目录时,mvcMailer 抱怨 SMTP 主机
这让我很紧张,因为我找不到它不起作用的理由。我有一个 mvcMailer 代码,如果我在 web.config 中指定使用 SMTP,该代码就可以工作。但我不想使用 SMTP,我想使用投递文件夹。这是执行发送的代码的一部分:
[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);
}
如果 web.config 文件配置如下,则此代码可以工作:
<smtp from="[email protected]">
<network enableSsl="false" host="192.168.111.11" port="25" userName="[email protected]" password="password" />
</smtp>
但是这些替代方案都不起作用,它们都给出相同的错误(未指定 SMTP 主机):
<smtp deliveryMethod="SpecifiedPickupDirectory">
<specifiedPickupDirectory pickupDirectoryLocation="C:\inetpub\mailroot\pickup"/>
</smtp>
<smtp from="[email protected]" deliveryMethod="SpecifiedPickupDirectory">
<specifiedPickupDirectory pickupDirectoryLocation="C:\inetpub\mailroot\pickup"/>
</smtp>
我猜值得注意,尽管出现错误,但无论如何都会在放置文件夹中创建一个文件。我只是不知道出了什么问题,根据我在 mvcmailer 上找到的内容,这是正确的配置。
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="[email protected]">
<network enableSsl="false" host="192.168.111.11" port="25" userName="[email protected]" 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="[email protected]" 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试如下所示的方法。下面的一项总是对我有用:
Try something like below. The below one always work for me: