ASP.NET从VStudio发送电子邮件运行速度很快,但在IIS中速度很慢(ASP.NET Send email from VStudio is running fast but very slow in IIS)
使用Visual Studio从我的ASP.NET项目发送电子邮件的速度非常快 - 它在一秒之内完成 - 但是当在同一台机器上的IIS 7中发布时,它需要50秒或更长时间。 有没有人遇到过这种速度降低? 我已将我的C#代码和我的设置粘贴到web.config中。 非常感谢你。
public static bool EnviarMail(String eOrigen, String eDestino, String asunto, String cueMensaje) { Boolean EstadoEnvio; MailMessage eMail = new MailMessage(); eMail.From = new MailAddress(eOrigen); eMail.To.Add(new MailAddress(eDestino)); eMail.Subject = asunto; eMail.IsBodyHtml = true; cueMensaje = cueMensaje.Replace("\r\n", "<BR>"); eMail.Body = cueMensaje; eMail.Priority = MailPriority.Normal; SmtpClient clienteSMTP = new SmtpClient(); try { clienteSMTP.Send(eMail); EstadoEnvio = true; } catch { EstadoEnvio = false; } return EstadoEnvio; }
并在我的web.config:
<mailSettings> <smtp from="iso@hmoore.com.ar"> <network host="174.120.190.6" port="25" userName="iso@hmoore.com.ar" password="-----" defaultCredentials="true"/> </smtp> </mailSettings>
To send an email from my ASP.NET project using Visual Studio is very fast--it does in one second--but when published in IIS 7 on the same machine, it takes 50 seconds or more. Has anyone encountered this reduction in speed before? I've pasted my C# code and my settings in the web.config. Thank you very much.
public static bool EnviarMail(String eOrigen, String eDestino, String asunto, String cueMensaje) { Boolean EstadoEnvio; MailMessage eMail = new MailMessage(); eMail.From = new MailAddress(eOrigen); eMail.To.Add(new MailAddress(eDestino)); eMail.Subject = asunto; eMail.IsBodyHtml = true; cueMensaje = cueMensaje.Replace("\r\n", "<BR>"); eMail.Body = cueMensaje; eMail.Priority = MailPriority.Normal; SmtpClient clienteSMTP = new SmtpClient(); try { clienteSMTP.Send(eMail); EstadoEnvio = true; } catch { EstadoEnvio = false; } return EstadoEnvio; }
And in my web.config:
<mailSettings> <smtp from="iso@hmoore.com.ar"> <network host="174.120.190.6" port="25" userName="iso@hmoore.com.ar" password="-----" defaultCredentials="true"/> </smtp> </mailSettings>
原文:https://stackoverflow.com/questions/14399056
最满意答案
而不是用空字符串替换文件名,最好用下划线替换它以保持文件的可读性和实际名称:
$file = str_replace(' ', '_', $file);
rather than replacing file name with empty string, it is good idea to replace it with an underscore to maintain the readability and actual name of the file in its sense:
$file = str_replace(' ', '_', $file);
相关问答
更多-
您只需将FTP filezilla中的访问权限全部上传到您要上传此文件的上传文件夹。我认为没有文件访问权限... You just give access right upload all in FTP filezilla to that upload folder where you want upload this file.i think there is no access right to files...
-
PHP使用空间上传图片(PHP upload pics with space)[2024-01-13]
而不是用空字符串替换文件名,最好用下划线替换它以保持文件的可读性和实际名称: $file = str_replace(' ', '_', $file); rather than replacing file name with empty string, it is good idea to replace it with an underscore to maintain the readability and actual name of the file in its sense: $file = s ... -
在表中添加5列不是理想的有效解决方案。 想想用户可以上传10张图片的场景。 然后? 当你的系统上线时你会改变表吗? 没有。 创建一个名为user_file_manager的新表。 始终在该表中添加记录并具有用户引用列。 因此,您始终可以知道哪个用户上传了多少文件和哪些文件。 也只是将图像名称存储在数据库表中,并在配置PHP文件中定义图像目录路径。 并在每个文件中使用该路径。 希望这可以帮助。 如果您想了解其他任何内容,请与我们联系。 Adding 5 columns in table is not a de ...
-
php图片上传无法将实际文件复制到目标文件夹(php image upload cant copy the actual file to the destination folder)[2021-12-24]
您是否检查了profile_pics目录的权限。 它应该是777。 或者与您在move_uploaded_file中使用的路径(目录的目标路径)相关的问题。 Have you checked the permission of the profile_pics directory . It should be 777. Or the issue related to the path (destination path of your directory )you have used in move_upl ... -
在URL中使用时,某些字符具有特殊含义。 这就是为什么你总是必须正确编码你的字符串作为网址的一部分。 使用Java,您可以使用URLEncoder类来完成这项工作。 所以你的 dos.writeBytes("Content-Disposition: post-data; name=uploadedfile;filename=" + path + "" + lineEnd); 应该看 dos.writeBytes("Content-Dispositio ...
-
PHP上传图片(PHP upload image)[2024-04-19]
没有move_uploaded_file语句存在。 有一个简单的例子: http://www.w3schools.com/php/php_file_upload.asp The code overlooks calling the function move_uploaded_file() which would check whether the indicated file is valid for uploading. You may wish to review a simple example a ... -
使用这个代码,你只需要插入查询。 休息一切都会正常工作。 if ((!empty($_FILES['uploadedfile']["name"])) && (!empty($_FILES['fileToUpload']["name"]))) { $file_name1=$_FILES['uploadedfile']["name"]; $temp_name1=$_FILES['uploadedfile']["tmp_name"]; $imagename1=date("d-m-Y")."-".time(); ...
-
在php上传图片(Upload image in php)[2023-08-23]
线索出现错误。 您尝试使用$targetpath = mkdir("pageimage/pageid");创建的目录$targetpath = mkdir("pageimage/pageid"); 已经存在......所以你不能再做了! 我建议在尝试制作它之前做一个快速文件存在检查。 有一个功能: file_exists() 另外, mkdir()返回一个布尔值(成功或失败); 不是文件目录,因此您将无法按预期使用$targetpath变量。 试试这个...... $targetpath = "pageim ... -
php图片上传(php image upload)[2023-08-02]
如果您有特定需求(例如安全性),或者像绝对需要将所有自定义数据保存在数据库中,则应该只在数据库中存储图像。 除此之外,将大文件放入数据库通常不值得。 存储和检索文件会使实现变得更加复杂,并且数据库更新/升级/转换会产生更多可能出错的问题。 You should only store images in your database if you have a specific need to, like security, or like an absolute to-die-for need to keep ... -
Nginx + PHP文件上传问题(Nginx + PHP File Upload issue)[2022-10-16]
简单解决方案 $ sudo systemctl restart php-fpm nginx 解决了这个问题。 我不知道为什么,但现在它的工作就像一个魅力。 Simple Solution: $ sudo systemctl restart php-fpm nginx Fixed the problem. I don't know why, but now it is working like a charm.