---
# System prepended metadata

title: Test Mail & Local mailing solution (SSH tunnel)
tags: [phishing]

---

# Test Mail & Local mailing solution (SSH tunnel)
###### tags: `phishing`

Now test if you can send an email with your created mail account. 

Install `swaks`: 

**Linux**

```
sudo apt install swaks
sudo apt-get install libnet-ssleay-perl
sudo apt-get install libcrypt-ssleay-perl
```

**Mac**

```
brew install swaks
```

Then you can send a test mail. Run this command from your server (not locally, unless you adjust your mail DNS records accordingly).

<details>
  <summary>Click to expand to view how to login to server</summary>
  
  ```bash
   ssh root@<your-ip> -i ~/.ssh/workshop
  ```
</details>



```
swaks -f test@yourdomain.be --server 127.0.0.1:587 -tlsos --auth-user test@yourdomain.com -body "This message is from the server" -t <receiver-address>
```

You can better use [https://www.mail-tester.com](https://www.mail-tester.com/) for testing, because if you are new to this, it will end up in the spam folder of your work or private mail when there was a mistake made in the setup.

![Mailtester](https://i.imgur.com/mKJWRQg.png)

Use a proxy in your browser if you need more than 3 retries at this website. Don't forget to clear the cookies before refreshing the page.

## Sent mails from your own IP (in case of mails not passing spam)

If a domain is not old enough (10 days), for example it is bought too late, you can sent email from your local machine which has a "good" IP. 

![SSH tunnel with phishing](https://i.imgur.com/Tjkkv01.png)

Make a folder on your machine and copy these files over:

![Cyberduck screenshot](https://i.imgur.com/m8kZvpj.png)

So in your downloadsfolder you have downloaded the files to a folder "mailserver". Run the following docker command to run a local mailserver:

So in your downloadsfolder you have downloaded the files to a folder "mailserver". Run the following docker command to run a local mailserver:

```bash
docker run \
    -d -p 25:25 \
    -p 999:80 \
    -p 9999:443 \
    -p 110:110 \
    -p 143:143 \
    -p 465:465 \
    -p 587:587 \
    -p 993:993 \
    -p 995:995 \
    -v /etc/localtime:/etc/localtime:ro \
    -v /Users/vincentcox/Downloads/mailserver:/data \
    -t analogic/poste.io
```

Now you can make the server sent a mail via your local machine:‌

```bash
ssh -R 6969:127.0.0.1:587 -o StrictHostKeyChecking=no -i ~/.ssh/workshop root@xxxxxxxx
```

**Make sure to add your IP in the SPF record (in cloudflare)!**