I am trying to send an email using exchange.
My code is cookie cutter, copied from the documentation:
Added an SMTPSocket called SMTPSocket1
[code] Dim mail as EmailMessage
Dim file as EmailAttachment
Dim i as Integer
Dim s as String
SMTPSocket1.address = “mail.myexchange.com”
SMTPSocket1.port = 25
SMTPSocket1.username = “myemail”
SMTPSocket1.password = “mypassword”
mail = New EmailMessage
mail.bodyPlainText = “test”
mail.headers.appendHeader “X-Mailer”,“REALbasic SMTP Demo”
//send the mail
SMTPSocket1.messages.append mail //add email to list of messages
SMTPSocket1.SendMail //send message[/code]
It fails telling me “Can’t relay.”
The server error I get is this:
550 5.7.1 Unable to relay
and the code I get on the client is 102
Funny thing is: I am using a local Xojo Copy, and I can send emails with the exact same configuration just fine from any other client.
I must be missing something. If you could think of why this is not working, I would really appreciate your comments.
Are you sure that you don’t use any Encryption or Authentification? It would be helpful to see what your server-side SMTP Log is telling. Your message tells me, that your Exchange Server identify your Sender or Computer as something from outside your Domain.
Also, make sure you have an SMTP connector set up in exchange. Otherwise it won’t allow connections outside of outlook.
Authentication is set to “username and password”
I will check the security settings
Are you sure the username is just username and not the full email address?
Ah I guess the “myemail” part solved that. No relaying generally means this SMTP server doesn’t want to send an email on behalf of another domain. Does “myemail” = “email@example.com”?
Are you sure it’s the “exact” same configuration? Using SMTP instead of an Exchange connection?
If this is an internally hosted Exchange server, it’s possible that this hostname resolves to the “public” or internet facing connection, which very likely is configured to not allow SMTP client connections for sending mail (relaying). Internal clients usually connect to a different hostname that only resolves on the internal network.
Thank you guys!
It turns out we had a rule preventing SMTP relays from outside world. We had to allow a specific IP to send relays and that made it work.
I have the same problem: what do you mean please with "We had to allow a specific IP to send relays "? Is it something to ask to the exchange manager? Is it something in the cose? I go on with SSLconnected=false…