Can I send emails without authenticating on the SMTP server?

前端 未结 2 2031
悲哀的现实
悲哀的现实 2021-01-06 09:09

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

相关标签:
2条回答
  • 2021-01-06 09:41

    In general, you can, sure. In your concrete example code you are using GMail which does not allow anonymous sending.

    From their references:

    smtp.gmail.com (use authentication)
    Use Authentication: Yes
    Port for TLS/STARTTLS: 587
    Port for SSL: 465

    An additional comment regarding your catch clause:

    In my opinion you are heavily misusing the exception idea. A better aproach would be something like:

    catch(Exception x)
    {
        var s = x.Message;
        if ( x.InnerException!=null )
        {
            s += Environment.NewLine + x.InnerException.Message;
        }
    
        MessageBox.Show(s);
    }
    
    0 讨论(0)
  • 2021-01-06 09:45

    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?

    0 讨论(0)
提交回复
热议问题