Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can i disable the relaying and use my code as an authenticated client?
    primarykey
    data
    text
    <p>So there are many posts on this error i'm getting. But most deal with IIS. </p> <blockquote> <p>Mailbox unavailable. The server response was: 5.7.1 Unable to relay</p> </blockquote> <p>I have ported my code to console to see if i still get this error, and i do. It would seem as though it's still using ISS as a relay or something even though this is a console application?</p> <p>I have spoken to the Exchange Admin and he is not going to open up the mail server for any relaying or allow my server to do so. So i would like to make my C# code send out the email as a regular authenticated client as if it were outlook. </p> <p>My code below works if i'm sending it to someone within my own domain but not if the recipient is outside the domain. </p> <p><strong>How can i disable the relaying and use my code as an authenticated client so i can send emails to people outside my domain?</strong></p> <p>CODE:</p> <pre><code>static void Main(string[] args) { Console.WriteLine("Sending Mail..."); try { SmtpClient _SMTPServer = new SmtpClient("companymailserver", 587); _SMTPServer.Credentials = new System.Net.NetworkCredential("myusername", "mypassword"); MailMessage _mailMessage = new MailMessage(); _mailMessage.To.Add(new MailAddress("someone@gmail.com")); _mailMessage.From = new MailAddress("myself@mycompanydomain.com"); _mailMessage.IsBodyHtml = false; _mailMessage.Subject = "This is a test"; _mailMessage.Body = "This is the body"; _SMTPServer.Send(_mailMessage); } catch (Exception err) { Console.WriteLine("error: " + err.Message); } Console.WriteLine("Press any key to continue..."); Console.Read(); } </code></pre> <hr> <p><strong>UPDATE #1</strong></p> <p>The strange thing is no matter what credentials i put i get the same 'Unable to relay' error. As if it's defaulting to relay and ignoring my SmtpClient settings.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload