Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client does not have permission to submit mail to this server #9

Open
nibro7778 opened this issue Apr 8, 2020 · 2 comments
Open

Client does not have permission to submit mail to this server #9

nibro7778 opened this issue Apr 8, 2020 · 2 comments

Comments

@nibro7778
Copy link

nibro7778 commented Apr 8, 2020

While sending an email using the following code. I am getting an error Client does not have permission to submit mail to this server. The server response was: 4.7.1 <[email protected]>: Relay access denied

NOTE: This same code working fine if I changed to address [email protected] to testtocode@localhost

[Fact]
public void TestEmail()
{
  try
  {
       var message = new MailMessage();
       message.To.Add("[email protected]");
       message.From = new MailAddress("[email protected]");
       message.Subject = "Test Code Subject";
       message.Body = "Test Code body";
       message.IsBodyHtml = true;

       using (var client = new SmtpClient())
       {
             var host = "XXXXXX"; // SMTP Server address
             var userName = "";
             var password = "";
             var port = 2025;
             var enableSsl = false;
                  
             client.Host = host;
             client.Port = port;
             client.Credentials = new NetworkCredential(userName, password);
             client.EnableSsl = enableSsl;
             client.Timeout = 240000;
             client.Send(message);
          }
       }
      catch (SmtpFailedRecipientException sfex)
      {
            var test = sfex;
      }
      catch (Exception ex)
      {
           var test1 = ex;
      }
}
@fjakop
Copy link

fjakop commented Oct 22, 2021

same for me. When I run mailtrap on localhost with docker-compose it accepts all emails.
On OpenShift / Kubernetes every email address not on '@localhost' is denied.

@jeffrichards
Copy link

I ran into this as well, there's a fork over here https://github.com/agilesyndrome/edw.docker.mailtrap
with this fork, you get access to set some additional options the ones that we're important for me were

MT_POSTFIX_OPTIONS="mynetworks = #.#.#.#/16"

under the covers the image adds to the main.cf postfix config the options given to this environment variable and the "mynetworks_style" with a default value of "subnet" (see http://www.postfix.org/postconf.5.html#mynetworks_style for details).

If you set the mynetworks= to a subnet that makes sense for to allow your other hosts to send then you should avoid the dreaded Relay access denied

One gotcha with the image over there, and probably this image too, stable-slim has moved on as debian has made new releases, so for me to build this I had to set that to oldstable-slim

jeffrichards pushed a commit to jeffrichards/edw.docker.mailtrap that referenced this issue Jul 28, 2022
…reviously commited code by agilesyndrome addresses issue eaudeweb#9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants