如何将电子邮件发送给其他人帐户 [英] How to sen emails from to others account

查看:344
本文介绍了如何将电子邮件发送给其他人帐户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我写了发送电子邮件的代码,但它显示以下错误。请帮助。

尝试访问套接字被访问权限禁止的方式127.0.0.1:25



我的代码是

  protected   void  SendMail()
{
// 发送邮件的Gmail地址
var fromAddress = rajeshkumar.pani@gmail.com;
// 电子邮件将发送的任何地址
var toAddress = dsssweta@gmail.com;
// 您的Gmail地址密码
const string fromPassword = 1234\" ;
// 传递值并制作电子邮件格式以显示
string subject = ;
string body = From:< /跨度>;

// smtp设置
var smtp = new System.Net.Mail.SmtpClient();
{
smtp.Host = localhost;
smtp.Port = 25 ;
smtp.EnableSsl = true ;
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Credentials = new NetworkCredential(fromAddress,fromPassword);
// smtp.Timeout = 20000;
}
< span class =code-comment> //
将值传递给smtp对象
smtp.Send(fromAddress,toAddress,subject,body) ;
}

解决方案

我怀疑你是否在localhost上运行SMTP服务器。如果你知道这个服务器,你可能会提到它。您需要有一个真正的功能性SMTP服务器及其上的帐户,凭据允许您使用它。



-SA


请检查本地计算机上是否安装了SMTP服务器?如果已安装,则检查端口是否有效。


尝试smtp.EnableSsl = false;

因为某些smtps ssl将无法启用..

Hi everyone,
I wrote the code for sending email but it is showing the following error.Please help.
An attempt was made to access a socket in a way forbidden by its access permissions 127.0.0.1:25

My code is

protected void SendMail()
   {
       // Gmail Address from where you send the mail
       var fromAddress = "rajeshkumar.pani@gmail.com";
       // any address where the email will be sending
       var toAddress = "dsssweta@gmail.com";
       //Password of your gmail address
       const string fromPassword = "1234";
       // Passing the values and make a email formate to display
       string subject = "Hi";
       string body = "From: ";
      
       // smtp settings
       var smtp = new System.Net.Mail.SmtpClient();
       {
           smtp.Host = "localhost";
           smtp.Port = 25;
           smtp.EnableSsl = true;
           smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
           smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
          // smtp.Timeout = 20000;
       }
       // Passing values to smtp object
       smtp.Send(fromAddress, toAddress, subject, body);
   }

解决方案

I doubt that you are running a SMTP server on localhost. If you knew about this server, you would probably mention it. You need to have a "real" functional SMTP server and the account on it, with credentials allowing you to use it.

—SA


Please check whether SMTP server is installed on your local machine or not? If it is installed then check the port is valid or not.


try smtp.EnableSsl = false;
because for some smtps ssl will not be enabled..


这篇关于如何将电子邮件发送给其他人帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆