# Connecting GoPhish with Office365

### Enable SMTP

```
$UserCredential = Get-Credential 
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection 
Import-PSSession $Session -DisableNameChecking 
Take a look if it is True: Get-TransportConfig  (if there is True set to false) 
Set-TransportConfig -SmtpClientAuthenticationDisabled $false 
Take a look again if it works: Get-TransportConfig 
Remove-PSSession $Session 
```

Use the Administrator account (Generally the one which was used to create office365 account) to enable SMTP.  I have seen that newer accounts already have this setting enabled by **default.** If your account is not working try this out.

&#x20;UPDATE 01/02/2021&#x20;

If above doesn't work for you. Try the following code. Credits Jonathan Cheung&#x20;

```
Import-Module ExchangeOnlineManagement 
Connect-ExchangeOnline -UserPrincipalName abcd@blabla.com  -ShowProgress $true 
Set-TransportConfig -SmtpClientAuthenticationDisabled $false
```

### Add Connector

Go to [https://admin.exchange.microsoft.com/#/homepage ](https://admin.exchange.microsoft.com/#/homepage)and add a connector.&#x20;

![Add Connector to Exchange Admin](/files/-MNxZlF-l60jZBY6gtZl)

You will need to provide you GoPhish External IP to add this connector. The connector properties are From: Organization Mail Server , To: Office365, and then you need to add your External GoPhish IP

### Whitelist your External GoPhish IP

Go to exchange admin center ([https://admin.exchange.microsoft.com/#/homepage ](https://admin.exchange.microsoft.com/#/homepage)) and click on **Classic Exchange Admin** at the bottom of the side menu.

Click on Connection -> Protection Filter > Connection Filtering

Here you need to Whitelist your external Exchange IP&#x20;

![Whitelist your External GoPhish IP](/files/-MNxaJliD955WlRUkTNz)

You should be good to go now. Enter your creds inside Gophish and send a Test Email.

### Credit

[Vincent Yiu](https://twitter.com/vysecurity), [Jonathan Cheung](https://www.linkedin.com/in/jonathan-cheung-0a8208138/), [Jason Lang](https://twitter.com/curi0usjack)

### Connect with me

Twitter: <https://twitter.com/shantanukhande>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.redteam.cafe/phishing/connecting-gophish-with-office365.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
