Tag Archives: email

How to forward emails in Office 365

You want an easy way to forward all mails for one or more user(s) to another user? There are several ways to achieve this. One of them is to run the following command in powershell after you connect to Office 365.

[codesyntax lang="powershell"]

Set-Mailbox user1 -ForwardingSmtpAddress user2@example.com -DeliverToMailboxAndForward $false

[/codesyntax]

In this case, user1 is the mailbox you wish to forward mail for, and user2@example.com is the address that you would like to forward the email to. Because we set DeliverToMailboxAndForward to false, a copy of the email will NOT be kept in the Office 365 mailbox.

Do you want to turn off the forwarding?

[codesyntax lang="powershell"]

Set-Mailbox user1 -ForwardingSmtpAddress $null

[/codesyntax]

If you want to check ForwardingSmtpAddress just issue the following command:

[codesyntax lang="powershell"]

Get-Mailbox -Identity user1 | fl DeliverToMailboxAndForward,ForwardingAddress,ForwardingSmtpAddress

[/codesyntax]

Note: if you don't know how to connect to Office 365 from powershell please read this post.

Setup Gitolite v3 and Email Notifications

The most common setting would be to configure the email hooks to send notifications on a push operation. This is not hard, however, I found the information of how to setup email notifications are pieces and pieces everywhere online, some of them are targeting Gitolite v2, and some of them are misleading. After tried some approaches, and here is what works for me.

1. Setup hook scripts

I tried

[codesyntax lang="bash"]

ln -s /usr/share/doc/git/contrib/hooks/post-receive-email /home/git/.gitolite/hooks/common/post-receive

[/codesyntax]

However, my git user doesn’t have the permission to execute this script. So, finally, I decided to simply copy the script to user folder. Don’t forget to setup Gitolite (again) after put hook scripts into place, so that Gitolite can deploy scripts to all bare repositories.

[codesyntax lang="bash"]

cp /usr/share/doc/git/contrib/hooks/post-receive-email /home/git/.gitolite/hooks/common/post-receive
chmod a+x /home/git/.gitolite/hooks/common/post-receive
$HOME/bin/gitolite setup --hooks-only

[/codesyntax]

2. Setup .gitolite.rc

Edit ~/.gitolite.rc file, and change GIT_CONFIG_KEYS as '.*',

[codesyntax lang="bash"]

vim /home/git/.gitolite.rc
:%s/'',/'.*',/
:wq

[/codesyntax]

If you skip this step, following errors will be presented when attempt to push repository specific configurations.

remote: FATAL: git config 'hooks.mailinglist' not allowed
remote: check GIT_CONFIG_KEYS in the rc file

If you installed git using my previous article about how to migrate from svn to git then you already have changed this.

3. Setup repositories

For the repositories desire to send email notifications, add

config hooks.mailinglist = 'user1@example.com, user2@example.com'
config hooks.emailprefix = '[repo_name] '

to local gitolite-admin repository as discribed in the Giolite README, then push.