我可以发送电子邮件没有SMTP服务器上进行身份验证? [英] Can I send emails without authenticating on the SMTP server?

查看:444
本文介绍了我可以发送电子邮件没有SMTP服务器上进行身份验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建简单的电子邮件发送程序。在我的应用程序时,曾经我发电子邮件,我必须把我的电子邮件地址或密码从,但我不希望使用密码,只希望把电子邮件

所以

我可以发送电子邮件,而无需使用密码使用C#/。NET应用程序?

这是我的code:

 尝试
    {
        //设置邮件
        MailMessage消息=新MailMessage();
        message.From =新MailAddress(textBox1.Text);
        message.To.Add(新MailAddress(textBox2.Text));
        message.Subject = textBox3.Text;
        message.Body = richTextBox1.Text;

        //设置邮件客户端
        SmtpClient的MailCli​​ent =新SmtpClient(smtp.gmail.com);
        mailCli​​ent.Credentials =新的NetworkCredential(textBox1.Text,密码);

        // 发信息
        mailCli​​ent.Send(消息);

        的MessageBox.show(已发送);
    }
    赶上(例外)
    {
        的MessageBox.show(错误);
    }
 

解决方案
  

我可以发送电子邮件,而无需使用密码使用C#/。NET应用程序?

是的,如果你有机会到邮件网关,不需要身份验证,您可以简单地做:

  SmtpClient的MailCli​​ent =新SmtpClient(your.emailgateway.com);
mailCli​​ent.Send(消息);
 

也许你的公司或ISP可以为您提供一个吗?

i am creating simple email sending application. In my application when ever i send email i have to put my email address or password as from but i don't want to use password only want to put email

so

Can i send Email without using password using c#/.net application ?

this is my code:

   try
    {
        // setup mail message
        MailMessage message = new MailMessage();
        message.From = new MailAddress(textBox1.Text);
        message.To.Add(new MailAddress(textBox2.Text));
        message.Subject = textBox3.Text;
        message.Body = richTextBox1.Text;

        // setup mail client
        SmtpClient mailClient = new SmtpClient("smtp.gmail.com");
        mailClient.Credentials = new NetworkCredential(textBox1.Text,"password");

        // send message
        mailClient.Send(message);

        MessageBox.Show("Sent");
    }
    catch(Exception)
    {
        MessageBox.Show("Error");
    }

解决方案

Can i send Email without using password using c#/.net application ?

Yes, if you have access to an email gateway that doesn't require authentication you can simply do:

SmtpClient mailClient = new SmtpClient("your.emailgateway.com");
mailClient.Send(message);

Maybe your company or ISP can provide one for you?

这篇关于我可以发送电子邮件没有SMTP服务器上进行身份验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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