I've been trying to figure out what I'm doing wrong for a considerable amount of time and still no avail. I was wondering if anyone here could recognise whether there's something noticeably incorrect with the following.
I'm setting up relaying via SMTP, starting out in a C# .net service, where I'm sending a message via SMTP to PowerMTA, I'm using the following to do so:
    MailMessage msg = new MailMessage();
    SmtpClient client = new SmtpClient("12.345.678.90", 25);
    client.Credentials = new NetworkCredential("myUsername", "myPassword");
    msg.Body = "<html><head></head><body><h1>Hello World</h1></body></html>";
    msg.To.Add("recipient@adomain.com");
    msg.From = new MailAddress("sender@mydomain.com", "Sender");
    msg.IsBodyHtml = true;
    msg.Subject = "Local Relay Test";
    client.Send(msg);
Here's a snippet from my PowerMTA configuration, that corresponds to my sent message:
<smtp-user myUsername>  
  password myPassword
  source {auth}  
</smtp-user>
<source {auth}>
    always-allow-relaying yes    # allow feeding for defined users
    process-x-virtual-mta yes    # allow selection of a VirtualMTA
    max-message-size 0           # 0 implies no cap, in bytes
    smtp-service yes             # allow SMTP service
    default-virtual-mta myVmta
    require-auth true
    log-connections yes
    log-commands    yes         # WARNING: verbose!
</source>
I also have a general source 0/0 with logging turned on and always-allow-relaying set to no.
When I run through my code I get the following exception:
An unhandled exception of type 'System.Net.Mail.SmtpFailedRecipientException' occurred in System.dll
Additional information: Mailbox unavailable. The server response was: 5.7.1 relaying denied: <recipient@adomain.com> in "RCPT TO:<recipient@adomain.com>"
Although when I view the logs in PowerMTA, it seems to hit my general rule of 0/0 and not the {auth} source. There is absolutely no sign of a username and password being passed across. Am I missing something obvious?
I've also tested this locally on the server where PowerMTA is hosted, it just hits the 0/0 source and not the {auth} source again.