<small id='UcNL1'></small><noframes id='UcNL1'>

        <i id='UcNL1'><tr id='UcNL1'><dt id='UcNL1'><q id='UcNL1'><span id='UcNL1'><b id='UcNL1'><form id='UcNL1'><ins id='UcNL1'></ins><ul id='UcNL1'></ul><sub id='UcNL1'></sub></form><legend id='UcNL1'></legend><bdo id='UcNL1'><pre id='UcNL1'><center id='UcNL1'></center></pre></bdo></b><th id='UcNL1'></th></span></q></dt></tr></i><div id='UcNL1'><tfoot id='UcNL1'></tfoot><dl id='UcNL1'><fieldset id='UcNL1'></fieldset></dl></div>
        <legend id='UcNL1'><style id='UcNL1'><dir id='UcNL1'><q id='UcNL1'></q></dir></style></legend>
        • <bdo id='UcNL1'></bdo><ul id='UcNL1'></ul>

        <tfoot id='UcNL1'></tfoot>

        使用 SMTP 发送电子邮件并控制发件人地址

        时间:2023-10-05
          <i id='YOaTM'><tr id='YOaTM'><dt id='YOaTM'><q id='YOaTM'><span id='YOaTM'><b id='YOaTM'><form id='YOaTM'><ins id='YOaTM'></ins><ul id='YOaTM'></ul><sub id='YOaTM'></sub></form><legend id='YOaTM'></legend><bdo id='YOaTM'><pre id='YOaTM'><center id='YOaTM'></center></pre></bdo></b><th id='YOaTM'></th></span></q></dt></tr></i><div id='YOaTM'><tfoot id='YOaTM'></tfoot><dl id='YOaTM'><fieldset id='YOaTM'></fieldset></dl></div>

          • <bdo id='YOaTM'></bdo><ul id='YOaTM'></ul>
            <tfoot id='YOaTM'></tfoot>
              <legend id='YOaTM'><style id='YOaTM'><dir id='YOaTM'><q id='YOaTM'></q></dir></style></legend>

                <tbody id='YOaTM'></tbody>
              • <small id='YOaTM'></small><noframes id='YOaTM'>

                1. 本文介绍了使用 SMTP 发送电子邮件并控制发件人地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试使用 c# App 发送电子邮件,下一个代码正在运行.

                  I'm trying to send an email using c# App, the next code is working.

                  SmtpClient MailClient = new SmtpClient("smtp.gmail.com");
                  MailClient.EnableSsl = false;
                  MailClient.Credentials = new NetworkCredential("Ryan.White", "Password");
                  MailMessage Msg = new MailMessage();
                  Msg.From = new MailAddress("Sender.name@gmail.com");
                  Msg.To.Add(new MailAddress("Ryan.White@gmail.com"));
                  Msg.Subject = "testSub";
                  Msg.Body = "testBody";
                  
                  MailClient.Send(Msg);
                  

                  但 Gmail 的 SMTP 服务器将 gmail 电子邮件地址 (Ryan.White@gmail.com) 作为发件人,

                  But Gmail's SMTP server puts gmail e-mail address (Ryan.White@gmail.com) as the sender,

                  不管 MSG.FROM 地址 (Sender.name@gmail.com).

                  regardless the MSG.FROM address (Sender.name@gmail.com).

                  是否可以使用 C#/.NET 发送电子邮件并控制发件人地址?

                  或者发送一封不经过身份验证的电子邮件?

                  Or alternatively send an email without authentication?

                  我知道在 UNIX 中,您可以在邮件"命令中控制发件人地址.

                  I know that in UNIX you can control the sender address in 'Mail' command.

                  推荐答案

                  Gmail 这样做是出于安全原因,否则垃圾邮件发送者很容易发送看似来自虚假地址的电子邮件.

                  Gmail is doing that for security reasons, otherwise it would be easy for spammers to send emails that appear to come from fake addresses.

                  您已正确编码,C# 将尝试将发件人地址设置为 Sender.Name@gmail.com,但 SMTP 服务器拥有最终决定权.如果您有权以其他用户的身份发送邮件,这将起作用,例如在 Exchange 服务器环境中您被验证为管理员的情况.但是,Gmail 似乎不允许这样做.您需要以 Sender.name 身份登录才能以该用户身份发送电子邮件.

                  You have coded this correctly, and C# will attempt to set the from address as Sender.Name@gmail.com, but the SMTP server has the final say. If you had authorization to send as another user, this would work, like in the case of an Exchange server environment where you are authenticated as an admin. However, Gmail doesn't seem to allow this. You would need to login as Sender.name to be able to send emails as that user.

                  这篇关于使用 SMTP 发送电子邮件并控制发件人地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:收到 ASP 错误:邮箱不可用.服务器响应是:访问被拒绝 - HELO 名称无效(请参阅 RFC2821 4.1.1.1 下一篇:是否有用于通过代理发送电子邮件的 .NET 库?

                  相关文章

                  <i id='7RxdH'><tr id='7RxdH'><dt id='7RxdH'><q id='7RxdH'><span id='7RxdH'><b id='7RxdH'><form id='7RxdH'><ins id='7RxdH'></ins><ul id='7RxdH'></ul><sub id='7RxdH'></sub></form><legend id='7RxdH'></legend><bdo id='7RxdH'><pre id='7RxdH'><center id='7RxdH'></center></pre></bdo></b><th id='7RxdH'></th></span></q></dt></tr></i><div id='7RxdH'><tfoot id='7RxdH'></tfoot><dl id='7RxdH'><fieldset id='7RxdH'></fieldset></dl></div>
                  <legend id='7RxdH'><style id='7RxdH'><dir id='7RxdH'><q id='7RxdH'></q></dir></style></legend>

                      • <bdo id='7RxdH'></bdo><ul id='7RxdH'></ul>
                    1. <small id='7RxdH'></small><noframes id='7RxdH'>

                      <tfoot id='7RxdH'></tfoot>