x
I'm sorry, but you have been denied access to edit this topic.
chris.cardinal66
sad I’m confused

Getting "Relay access denied" error - critical failure

Sending email via .Net SMTP class (in System.Net.Mail).
Send() method returns error:
Transaction failed. The server response was: 5.7.1 : Relay access denied

Have tried a couple of different email addresses. Same result.
C# Code is below:

MailMessage message = new MailMessage("XXXXXXXXXXXXXXXXXXXXXXX", "chris.cardinal66@gmail.com", "CloudServer check failure. ***URGENT***", msg);
SmtpClient emailClient = new SmtpClient("smtp.sendgrid.net");
System.Net.NetworkCredential SMTPUserInfo = new System.Net.NetworkCredential("YYYYYYYYYYYYYYYYYYYYY", "XXXXXXXXXXXXXXX");
emailClient.UseDefaultCredentials = false;
emailClient.Credentials = SMTPUserInfo;
emailClient.Send(message);

Looks like your server is not relaying.
5 people have
this problem
+1
Reply

  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited sad, anxious, confused, frustrated

  • rob.s.reagan
    Your code is correct. I talked with SendGrid's support staff about this issue. They told me that either my firewall or ISP was blocking outbound connections on port 25. You can check to see by dropping to a command prompt and running "telnet". Use the command "o smtp.sendgrid.net 25" to attempt to connect. If you can connect, there's a problem with your code. If you cannot, there is a problem with either your firewall or ISP blocking outbound traffic.

    SendGrid also opens up another port for SSL traffic which you can try.

    My code didn't run on my local machine and I couldn't connect via telnet, but worked like a charm when I uploaded it to my production hosting environment.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited sad, anxious, confused, frustrated

  • Jacob (Support Engineer) October 12, 2011 13:43
    Rob's right,

    The best way to verify your connection is the following:
    Open Command Prompt/Terminal (depending on your OS)
    If you have Windows, you might have to enable or install telnet. Google "telnet [your version of Windows]
    Type the following:
    telnet smtp.sendgrid.net 25
    If 25 fails, also try 465, or 587.

    If you get a "220" type return, you have a valid connection, and you need to see why your code isn't doing this. If you don't get a valid connection, you may need to talk to your host about allowing external SMTP connections.

    If you try this, and still have problems, please aemail us or call us at 303-552-0653.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited sad, anxious, confused, frustrated