最近很多小伙伴都在问asp.net–System.Net.Mail.SmtpFailedRecipientException:不允许使用邮箱名称和不可使用邮箱域名什么意思这两个问题,那么本篇文章就来给
最近很多小伙伴都在问asp.net – System.Net.Mail.SmtpFailedRecipientException:不允许使用邮箱名称和不可使用邮箱域名什么意思这两个问题,那么本篇文章就来给大家详细解答一下,同时本文还将给你拓展.Net错误:System.ArgumentException:'不支持的关键字:'trustedconnection'、Android java.net.SocketException:socket failed:EACCES(Permission denied)、android – java.net.SocketException:sendto failed:ECONNRESET(由peer重置连接)、android – java.net.SocketException:sendto failed:EPIPE(Broken pipe)通过与localhost的数据连接等相关知识,下面开始了哦!
本文目录一览:- asp.net – System.Net.Mail.SmtpFailedRecipientException:不允许使用邮箱名称(不可使用邮箱域名什么意思)
- .Net错误:System.ArgumentException:'不支持的关键字:'trustedconnection'
- Android java.net.SocketException:socket failed:EACCES(Permission denied)
- android – java.net.SocketException:sendto failed:ECONNRESET(由peer重置连接)
- android – java.net.SocketException:sendto failed:EPIPE(Broken pipe)通过与localhost的数据连接
asp.net – System.Net.Mail.SmtpFailedRecipientException:不允许使用邮箱名称(不可使用邮箱域名什么意思)
System.Net.Mail.SmtpFailedRecipientException:不允许使用邮箱名称.服务器响应是:抱歉,该域不在我的System.Net.Mail.SmtpClient.Send(MailMessage消息)中允许的rcpthosts(#5.7.1)列表中
有没有什么办法解决这一问题?
如果我们必须在允许的rcphosts列表中添加此域,那该怎么办呢?
编写的代码是这样的:
MailMessage message; bool success; message = new MailMessage(from,to); Attachment file; SmtpClient lclient; lclient = new SmtpClient("mail.domain1.com",587); lclient.EnableSsl = false; message.Body = body; message.BodyEncoding = System.Text.Encoding.UTF8; message.IsBodyHtml = true; message.Subject = subject; message.SubjectEncoding = System.Text.Encoding.UTF8; lclient.SendCompleted += new SendCompletedEventHandler(SendCompletedCallback); lclient.UseDefaultCredentials = false; lclient.Credentials = new NetworkCredential(userID,password); try { lclient.Send(message); success = true; if (message != null) message.dispose(); success = true; return (success); } catch (Exception ex) { //... }
谢谢
解决方法
请注意,这是SMTP服务的常见做法.他们通常不允许任何人通过他们发送邮件到任何地址. (这会使他们对垃圾邮件发送者和其他此类不受欢迎的活动敞开大门.)因此,如果您尝试从Domain1外部访问Domain1的SMTP服务,那么可能只是拒绝这一点.
.Net错误:System.ArgumentException:'不支持的关键字:'trustedconnection'
如何解决.Net错误:System.ArgumentException:''不支持的关键字:''trustedconnection''?
我有一个尝试使用.Net编写的应用程序。我有一个SeedData.cs类,我试图使用该类来填充数据库,但是遇到一些连接问题,并且继续出现错误:System.ArgumentException:''不支持的关键字:''trustedconnection''。行:
if (!context.Products.Any())
我认为这可能是由于我的数据库连接造成的,但是无论如何这是我的代码:
// SeedData.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
namespace Sportsstore.Models
{
public static class SeedData
{
public static void EnsurePopulated(IApplicationBuilder app)
{
ApplicationDbContext context = app.applicationservices.GetrequiredService<ApplicationDbContext>();
if (!context.Products.Any())
{
context.Products.AddRange(
new Product
{
Name = "Kayak",Description = "A boat for one person",Category = "Watersports",Price = 275
},new Product
{
Name = "Lifejacket",Description = "Protective and fashionable",Price = 48.95m
},new Product
{
Name = "Soccer Ball",Description = "FIFA-approved size and weight",Category = "Soccer",Price = 19.50m
},new Product
{
Name = "Corner Flags",Description = "Give your playing field a professional touch",Price = 34.95m
},new Product
{
Name = "Stadium",Description = "Flat-packed 35,000-seat stadium",Price = 79500
},new Product
{
Name = "Thinking Cap",Description = "Improve brain efficiency by 75%",Category = "Chess",Price = 16
},new Product
{
Name = "Unsteady Chair",Description = "Secretly give your opponent a disadvantage",Price = 75
},new Product
{
Name = "Bling-Bling King",Description = "Gold-plated,diamond-studded King",Price = 1200
}
);
context.SaveChanges();
}
}
}
}
appsettings.json:
"Data": {
"SportStoreProducts": {
"ConnectionString": "Server=(localdb)\\MSsqlLocalDB;Database=Sportsstore;TrustedConnection=True;MultipleActiveResultSets=true"
}
}
// startup.cs
public class Startup
{
IConfigurationRoot Configuration;
public Startup(IHostEnvironment env)
{
Configuration = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json").Build();
}
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application,visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<ApplicationDbContext>(options =>
options.UsesqlServer(
Configuration["Data:SportStoreProducts:ConnectionString"])); // loads configuration settings in the appsettings.json file and makes them available through a property called Configuration.
services.AddTransient<IProductRepository,EFProductRepository>();
services.AddMvc(options => options.EnableEndpointRouting = false);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app,IServiceProvider serviceProvider,IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseStatusCodePages();
app.UseStaticFiles();
}
app.UseRouting();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",template: "{controller=Product}/{action=List}/{id?}");
});
SeedData.EnsurePopulated(app);
}
}
}
// ApplicationDbContext.cs
namespace Sportsstore.Models
{
public class ApplicationDbContext : DbContext
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options) {} // provides access to Entity Framework Core''s underlying functionality
public DbSet<Product> Products { get; set; } // Provides access to the Product objects in the database.
}
}
解决方法
您的连接字符串中有错误。类型:
Trusted_Connection=True
Android java.net.SocketException:socket failed:EACCES(Permission denied)
这里代码MainActivity:
public class MainActivity extends Activity { private UdpClientServer cu; private EditText textIpScheda; private EditText textUdpPort; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); textIpScheda = (EditText) findViewById(R.id.textIpScheda); textUdpPort = (EditText) findViewById(R.id.textUdpPort); try { cu = new UdpClientServer(this); } catch (IOException e) { e.printstacktrace(); } } public EditText getTextIpScheda(){ return textIpScheda; } public void setTextIpScheda(EditText textIpScheda){ this.textIpScheda = textIpScheda; } public EditText getTextUdpPort() { return textUdpPort; } public void setTextUdpPort(EditText textUdpPort) { this.textUdpPort = textUdpPort; }
这里代码UdpClientServer:
public class UdpClientServer { public static String sReceive; private static DatagramSocket dSocket; int receiveBufferSize = 1024; int portUdp = 0; final String PINGACMD = "AT*PINGA001"; InetAddress ipScheda; byte[] receiveData = new byte[receiveBufferSize]; private MainActivity gui = null; public UdpClientServer(MainActivity gui) throws SocketException,IOException { this.gui = gui; portUdp = Integer.parseInt(String.valueOf(gui.getTextUdpPort().getText())); dSocket = new DatagramSocket(portUdp); } public void run(){ while (true) { // svuotamento buffer Arrays.fill(receiveData,(byte) 0); DatagramPacket receivePacket = new DatagramPacket(receiveData,receiveData.length); try { dSocket.receive(receivePacket); } catch (IOException e) { e.printstacktrace(); } ipScheda = receivePacket.getAddress(); int port = receivePacket.getPort(); gui.getTextUdpPort().setText("" + port); gui.getTextIpScheda().setText(ipScheda.getHostAddress()); sReceive = new String(receivePacket.getData()); this.sendCommand(PINGACMD); } } public void sendCommand(String outSentence){ byte[] sendData = outSentence.getBytes(); DatagramPacket sendPacket = new DatagramPacket(sendData,sendData.length,ipScheda,portUdp); try { dSocket.send(sendPacket); Thread.sleep(100); } catch (IOException e) { e.printstacktrace(); } catch (InterruptedException e) { e.printstacktrace(); } finally { } }
}
这里的logcat:
12-29 11:43:22.291 28914-28914/com.example.matteo.myfirstapp W/System.err﹕ java.net.socketException: socket Failed: EACCES (Permission denied) 12-29 11:43:22.294 28914-28914/com.example.matteo.myfirstapp W/System.err﹕ at libcore.io.IoBridge.socket(IoBridge.java:623) 12-29 11:43:22.294 28914-28914/com.example.matteo.myfirstapp W/System.err﹕ at java.net.PlainDatagramSocketImpl.create(PlainDatagramSocketImpl.java:93) 12-29 11:43:22.294 28914-28914/com.example.matteo.myfirstapp W/System.err﹕ at java.net.DatagramSocket.createSocket(DatagramSocket.java:157) 12-29 11:43:22.294 28914-28914/com.example.matteo.myfirstapp W/System.err﹕ at java.net.DatagramSocket.<init>(DatagramSocket.java:80) 12-29 11:43:22.294 28914-28914/com.example.matteo.myfirstapp W/System.err﹕ at com.example.matteo.myfirstapp.UdpClientServer.<init>(UdpClientServer.java:32) 12-29 11:43:22.294 28914-28914/com.example.matteo.myfirstapp W/System.err﹕ at com.example.matteo.myfirstapp.MainActivity.onCreate(MainActivity.java:24) 12-29 11:43:22.294 28914-28914/com.example.matteo.myfirstapp W/System.err﹕ at android.app.Activity.performCreate(Activity.java:5933) 12-29 11:43:22.294 28914-28914/com.example.matteo.myfirstapp W/System.err﹕ at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105) 12-29 11:43:22.294 28914-28914/com.example.matteo.myfirstapp W/System.err﹕ at android.app.ActivityThread.performlaunchActivity(ActivityThread.java:2251) 12-29 11:43:22.294 28914-28914/com.example.matteo.myfirstapp W/System.err﹕ at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360) 12-29 11:43:22.294 28914-28914/com.example.matteo.myfirstapp W/System.err﹕ at android.app.ActivityThread.access$800(ActivityThread.java:144) 12-29 11:43:22.294 28914-28914/com.example.matteo.myfirstapp W/System.err﹕ at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278) 12-29 11:43:22.294 28914-28914/com.example.matteo.myfirstapp W/System.err﹕ at android.os.Handler.dispatchMessage(Handler.java:102) 12-29 11:43:22.294 28914-28914/com.example.matteo.myfirstapp W/System.err﹕ at android.os.Looper.loop(Looper.java:135) 12-29 11:43:22.294 28914-28914/com.example.matteo.myfirstapp W/System.err﹕ at android.app.ActivityThread.main(ActivityThread.java:5221) 12-29 11:43:22.294 28914-28914/com.example.matteo.myfirstapp W/System.err﹕ at java.lang.reflect.Method.invoke(Native Method) 12-29 11:43:22.294 28914-28914/com.example.matteo.myfirstapp W/System.err﹕ at java.lang.reflect.Method.invoke(Method.java:372) 12-29 11:43:22.294 28914-28914/com.example.matteo.myfirstapp W/System.err﹕ at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) 12-29 11:43:22.294 28914-28914/com.example.matteo.myfirstapp W/System.err﹕ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) 12-29 11:43:22.294 28914-28914/com.example.matteo.myfirstapp W/System.err﹕ Caused by: android.system.ErrnoException: socket Failed: EACCES (Permission denied) 12-29 11:43:22.294 28914-28914/com.example.matteo.myfirstapp W/System.err﹕ at libcore.io.Posix.socket(Native Method) 12-29 11:43:22.294 28914-28914/com.example.matteo.myfirstapp W/System.err﹕ at libcore.io.BlockGuardOs.socket(BlockGuardOs.java:282) 12-29 11:43:22.294 28914-28914/com.example.matteo.myfirstapp W/System.err﹕ at libcore.io.IoBridge.socket(IoBridge.java:608) 12-29 11:43:22.294 28914-28914/com.example.matteo.myfirstapp W/System.err﹕ ... 18 more
在我的AndroidManifest.xml中刚刚添加了字符串
<uses-permission android:name="android.permission.INTERNET"/>
但它不行
你可以帮我吗?
谢谢
解决方法
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
android – java.net.SocketException:sendto failed:ECONNRESET(由peer重置连接)
我尝试使用此代码连接到服务器以上传图像.
try {
url = new URL(requestURL);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty("connection", "close");
System.setProperty("http.keepAlive", "false");
conn.setReadTimeout(15000);
conn.setConnectTimeout(15000);
conn.setRequestMethod("POST");
conn.setDoInput(true);
conn.setDoOutput(true);
OutputStream os = conn.getoutputStream();
BufferedWriter writer = new BufferedWriter(
new OutputStreamWriter(os, "UTF-8"));
writer.write(getPostDataString(postDataParams));
writer.flush();
writer.close();
os.close();
int responseCode = conn.getResponseCode();
if (responseCode == HttpsURLConnection.HTTP_OK) {
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
sb = new StringBuilder();
String response;
while ((response = br.readLine()) != null){
sb.append(response);
}
}
} catch (IOException e){
if (e.getMessage().indexOf("Connection reset by peer") > 0);
} catch (Exception e) {
e.printstacktrace();
}
我总是得到SocketException,就像上面一样.
04-26 18:53:26.091 13039-13092/kovacsdev.hu.facec W/System.err: java.net.socketException: sendto Failed: ECONNRESET (Connection reset by peer)
04-26 18:53:26.092 13039-13039/kovacsdev.hu.facec I/SurfaceTextureClient: [STC::queueBuffer] (this:0x53cf5360) fps:45.86, dur:1002.96, max:57.77, min:1.67
04-26 18:53:26.095 13039-13092/kovacsdev.hu.facec W/System.err: at libcore.io.IoBridge.maybeThrowAfterSendto(IoBridge.java:550)
04-26 18:53:26.096 13039-13092/kovacsdev.hu.facec W/System.err: at libcore.io.IoBridge.sendto(IoBridge.java:519)
04-26 18:53:26.096 13039-13092/kovacsdev.hu.facec W/System.err: at java.net.PlainSocketImpl.write(PlainSocketImpl.java:511)
04-26 18:53:26.096 13039-13092/kovacsdev.hu.facec W/System.err: at java.net.PlainSocketImpl.access$100(PlainSocketImpl.java:46)
04-26 18:53:26.096 13039-13092/kovacsdev.hu.facec W/System.err: at java.net.PlainSocketImpl$PlainSocketoutputStream.write(PlainSocketImpl.java:269)
04-26 18:53:26.096 13039-13092/kovacsdev.hu.facec W/System.err: at java.io.ByteArrayOutputStream.writeto(ByteArrayOutputStream.java:231)
04-26 18:53:26.096 13039-13092/kovacsdev.hu.facec W/System.err: at libcore.net.http.RetryableOutputStream.writetoSocket(RetryableOutputStream.java:70)
04-26 18:53:26.096 13039-13092/kovacsdev.hu.facec W/System.err: at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:814)
04-26 18:53:26.096 13039-13092/kovacsdev.hu.facec W/System.err: at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:293)
04-26 18:53:26.097 13039-13092/kovacsdev.hu.facec W/System.err: at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:505)
04-26 18:53:26.097 13039-13092/kovacsdev.hu.facec W/System.err: at kovacsdev.hu.facec.RequestHandler.sendPostRequest(RequestHandler.java:43)
04-26 18:53:26.097 13039-13092/kovacsdev.hu.facec W/System.err: at kovacsdev.hu.facec.UploadUI$1UploadImage.doInBackground(UploadUI.java:108)
04-26 18:53:26.097 13039-13092/kovacsdev.hu.facec W/System.err: at kovacsdev.hu.facec.UploadUI$1UploadImage.doInBackground(UploadUI.java:82)
04-26 18:53:26.097 13039-13092/kovacsdev.hu.facec W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:287)
04-26 18:53:26.097 13039-13092/kovacsdev.hu.facec W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:234)
04-26 18:53:26.098 13039-13092/kovacsdev.hu.facec W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
04-26 18:53:26.098 13039-13092/kovacsdev.hu.facec W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
04-26 18:53:26.098 13039-13092/kovacsdev.hu.facec W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
04-26 18:53:26.098 13039-13092/kovacsdev.hu.facec W/System.err: at java.lang.Thread.run(Thread.java:838)
04-26 18:53:26.098 13039-13092/kovacsdev.hu.facec W/System.err: Caused by: libcore.io.ErrnoException: sendto Failed: ECONNRESET (Connection reset by peer)
04-26 18:53:26.099 13039-13092/kovacsdev.hu.facec W/System.err: at libcore.io.Posix.sendtoBytes(Native Method)
04-26 18:53:26.099 13039-13092/kovacsdev.hu.facec W/System.err: at libcore.io.Posix.sendto(Posix.java:151)
04-26 18:53:26.100 13039-13092/kovacsdev.hu.facec W/System.err: at libcore.io.BlockGuardOs.sendto(BlockGuardOs.java:177)
04-26 18:53:26.100 13039-13092/kovacsdev.hu.facec W/System.err: at libcore.io.IoBridge.sendto(IoBridge.java:517)
UploadUI在第108行包含此代码段:
String result = rh.sendPostRequest(UPLOAD_URL,data);
其中rh代表RequestHandler.它应该在sql数据库中发布图片的细节,但服务器端代码似乎有效.
解决方法:
嗨我也面临同样的问题.现在解决使用下面的代码.我希望它也会帮助你..试试….
将此代码放在onCreate()中
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_upload_documents);
if (android.os.Build.VERSION.SDK_INT > 9) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
.permitAll().build();
StrictMode.setThreadPolicy(policy);
}
//Statement or Controls Declaration or your code
}
android – java.net.SocketException:sendto failed:EPIPE(Broken pipe)通过与localhost的数据连接
我在NPR项目中使用StreamProxy工作:
http://code.google.com/p/npr-android-app/source/browse/Npr/src/org/npr/android/news/StreamProxy.java?r=e4984187f45c39a54ea6c88f71197762dbe10e72
问题是它不能通过数据连接工作. NPR也遇到了同样的问题.
总而言之,此代理作为本地Web服务器运行,在应用程序和远程流之间建立接口.它使用生成的自定义端口在localhost 127.0.0.1上运行.
当服务器正在读取流数据时,它会将其复制到应用程序,因为您可以在StreamProxy的第223行阅读:
client.getoutputStream().write(buff,readBytes);
但是,该行通过数据连接产生此异常:
java.net.socketException: sendto Failed: EPIPE (broken pipe)
我不是套接字和流媒体方面的专家.在这种情况下,我没有得到wifi和数据连接之间的区别.
解决方法
首先确保您的客户端与您尝试加入的服务器具有相同的版本.如果您没有相同的版本,可以下载MCNostalgia并使用它来降级您的客户端.
更新Java
如果您不希望出现任何不兼容问题,那么我建议您安装最新的Java运行时环境(jre 7.0_05).在此之前,建议您卸载其他以前的版本.如果您的操作系统以32位运行,则仅安装32位(x86)版本.如果您有64位,请按照这个精确的顺序安装以64位开头,然后安装32位.
禁用不需要的网络主机
Hamachi和Virtual Box可能就是其中之一.它们可能会减慢或干扰您的连接.访问网络控制面板,然后单击“修改网卡”(或类似的东西).右键单击需要禁用的主机,然后单击“禁用”.
禁用防火墙
您可以在控制面板中访问防火墙设置并在那里禁用它.如果这不起作用,您可以尝试禁用路由器的防火墙.如果这些失败尝试禁用您的防病毒软件(不建议使用这些选项,因为黑客可以轻易地渗入您的计算机).
这也适用于:
> Internal exception: java.net.socketException: Software caused > connection abort: socket write error
关于asp.net – System.Net.Mail.SmtpFailedRecipientException:不允许使用邮箱名称和不可使用邮箱域名什么意思的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于.Net错误:System.ArgumentException:'不支持的关键字:'trustedconnection'、Android java.net.SocketException:socket failed:EACCES(Permission denied)、android – java.net.SocketException:sendto failed:ECONNRESET(由peer重置连接)、android – java.net.SocketException:sendto failed:EPIPE(Broken pipe)通过与localhost的数据连接的相关信息,请在本站寻找。
本文标签: