Powershell and Exchange - Set SMTP Primary address - powershell

I'm in an hybrid environement with Exchange 2016 and Office 365.
I wish to script the process to enable a Remote Mailbox, an change the primary SMTP address of a user.
By example, I have a user who Remote Mailbox has been enabled. He has a SMTP primary address like this: User1#My-Group.com
With the command below, I can change the SMTP primary address just fine:
#Disable Email Address Policy
Set-RemoteMailbox User1 -EmailAddressPolicyEnabled $false
#Change SMTP address
Set-RemoteMailbox User1 -PrimarySmtpAddress "User1#My-good-address.com"
Everything is just fine, when I go to my On Premise Exchange 2016, I can see my user1 addresses like that:
SMTP:User1#My-good-address.com
smtp:User1#My-Group.com
...
But, when I put back Email Address Policy to $True, I have this result on Exchange:
SMTP:User1#My-Group.com
smtp:User1#My-good-address.com
...
That doesn't happen when I do the change manually.
Does anyone know why I have this behavior?
Thanks in advance !

Problem solved...
I was just on the ONLY USER who was missing an attribute, and the wrong email policy was applied.

Related

postfix redirect e-mails from same domain to another mailserver

So my question is, for a company we have an old exchange server (they don't want to upgrade or transfer) that is nearly dying from e-mails. But these are just coming from one Mailbox.
So my plan was, redirect info#example.de to another mailbox like info#outlook.onmicrosoft.com.
The other E-Mails should be routed as expected...
# virtual postfix file
info#example.de info#outlook.onmicrosoft.com
#example.de #example.de
For this I also have a transport File.
example.de smtp:mx.mail.de
My problem now is, the redirect is getting bounced (User unknown in virtual alias table)
2B2DEE7: to=<timo.bergen#example.de>, relay=none, delay=0.08, delays=0.05/0.01/0/0.02, dsn=5.1.1, status=bounced (User unknown in virtual alias table)
Fixed this, just had to append the Domain to "mydestinations".
mydestination = $myhostname, web-p03.hosting.it.local, localhost.hosting.it.local, , localhost , example.de

cPanel email routing... if not found locally try remote

I've got a weird setup with my emails that I need someones brain to look at. I've got it setup like this so that most of my emails are on one server (server1) and then 1 single account is setup on a second server hidden from the rest (server2)
Email Sent to user1#domain.me
MX record for domain.me = mail.domain.me
A record for mail.domain.me = server1 (11.11.11.11)
Email forwarding rule forwards all email sent to user1#domain.me to user#2.domain.me
MX record for 2.domain.me = mail2.domain.me
A record for mail2.domain.me = server2 (22.22.22.22) a cpanel server
Email hits my server now addressed to user1#2.domain.me
Domain forwarding rule forwards all email sent to #2.domain.me to #domain.me
This works great however my mail routing in cpanel is set to local, and therefore when sending emails out on server2 (22.22.22.22) to users#domain.me they're always delivered locally first and foremost
Is there any way around this? so that outgoing mail on this domain obey's DNS records (the mx records) and delivers it firstly to server1 (11.11.11.11) as if it was being sent from any other domain, gmail etc. Perhaps if the account isn't found locally then send on out to the web? Or perhaps there is a way to setup an alias somehow to let the local account receive mail for user1#2.domain.me
Thanks for your time & efforts looking into this
Henry
Check if your remote domains are listed in /etc/remotedomains and /etc/secondarymx. Note that if your second server has a dns server, it will try fetch the dns data locally first.
I have 2 servers using cpanel where each server acts as the other's backup and I don't have the issue you described.

ssmtp: 550 invalid DNS MX or A/AAAA resource record

I am trying to send a mail from centos machine, but I came to a problem. I have installed "mail" and ssmtp inside my linux machine and I got this response when I try to send a mail.
ssmtp: 550 invalid DNS MX or A/AAAA resource record
FromLineOverride=YES
mailhub=smtp.1und1.de:587
UseSTARTTLS=YES
Of course, with the correct password and user.
I have tried already couple of users and everybody are returning the same.
I have tried even with my own user and the password that I have, but it won't work.
If you have any other approaches to this problem let me know also.
What am I doing wrong ?
The problem seems to be the FROM address for the SMTP envelope. Some SMTP servers will ignore an invalid value like Gmail for example (that's why it worked for me with Gmail) but if you're using 1und1 SMTP-Server you have to override the domain if it's not the same as the mail domain (e.g. if you're on a local test server).
You can override the domain in the /etc/ssmtp/ssmtp.conf:
Assuming your email is: my#yourdomain.de
rewriteDomain=yourdomain.de

MS Exchange Server SMTP name for PowerShell script

If I wamted to send an email from a recently migrated MS Outlook account on MS Exchange Server to a MS Hotmail account on IMAP using PowerShell 5 like this:
$splatr = #{
To = 'her#hotmail.com'
From = 'him#outlook.com'
Subject ='test'
Body ='test'
SmtpServer ='??????'
Port = 587
UseSSL = $true
}
Send-MailMessage #splatr -Credential him#outlook.com
where would I get the Outlook/Exchange Server SMTP name from, please?
If it were the other way around, I would use
SmtpServer ='smtp-mail.outlook.com'
Thank you.
From Outlook,
Start Microsoft Outlook.
Click the "File" tab on the ribbon and then click "Info."
Click the "Account Settings" button and then select "Account Settings."
Select the account for which you want to look up the SMTP information and then click the "Change" button.
Look in the field next to "Outgoing Mail Server (SMTP)" to determine what SMTP server your email account is using.
Click the "Cancel" button to return to the main Outlook window.
Alternative;
Type "nslookup". Your computer's DNS Server name and IP address will
be displayed.
Type "set type=mx" - This will cause NSLOOKUP to only return what are
known as MX (Mail eXchange) records from the DNS servers. For an
example, type "hotmail.com" or use your own domain name.

Plesk, Email with localy established domain where the mail server is external

i have a big problem with the setup for an Domain.
The Webservices are established on our Server but the Mail functions are on a Server of an other Company when we now want send an Email over our Server he tried to send it localy insted of sending it to an other server so he give back an no account here error.
Thanks for helping me out and friendly greetings.
Edit: OS Debian 6
Imap: Courier
Send: Postfix
CP: Plesk
Further to this, we are using Plesk 11.5.3 on a setup where a single mail service is activated for all domains.
So each domain cannot have the mail service turned on or off individually.
We had the same problem as Franco, and we fixed this by running the following command for each domain that had external email:
# /usr/local/psa/bin/mail --off domain.com
Works perfectly, and removes any previously created local email addresses from Postfix.
"The problem is because the server will attempt to deliver emails for the domain name locally by default. To resolve that problem you would need to set it to use the domain name's MX record."
The simple answer is to disable mail services for the subscription.
Untick the box for "Activate mail service on domain".