Using hMailServer for simple PBEM sends in-game

omeganot

Chieftain
Joined
Dec 10, 2010
Messages
48
Hello all!

I'm new here, and I can't say I post on forums all that much, but I do love me some Civ 4 PBEM. Like, for the last 10+ years love me some PBEM. Long ago we ran into problems sending turns directly from the game, most notably due to SSL and different ports than what civ defaults to. Had some password problems too, but those were practically forgotten at this point. I did some searches and it seems others around here have had the same problem semi-recently.

I'd like to lay out how I set up a SMTP relay server on my PC to take turns from Civ 4 and send them through my regular email provider.

FAQ
  • Does this work with PBEM trackers?
    • I have no idea. I don't use any right now. Try it out (if you send it a turn by email) and let me know. I'll update this thread.
  • What email providers can I use this with?
    • For all I know, all of them
  • How do I avoid getting blacklisted as an open SMTP server?
    • We'll limit the access, as I'll show in the guide
  • It seems I got an old turn sent to me when the player before me says they took the turn. What gives?
    • This is a Civ 4 thing if you take a turn twice. I've found it sends out the turn in your pbem saves folder before letting you overwrite the save that's there and send the work you just completed. You'll need to delete the turn from your pbem saves before you take the turn again. Why would you retake a turn? I dunno, perhaps you completely screwed something up and wanted a redo and don't have random seeds on. Perhaps hMailServer couldn't send the email (max retries) and you decided to retake rather than find and send along the save file. It happens.
Setup
Setup comes in two parts: installing and configuring hMailServer, and setting up the game.

hMailServer
Start by going to https://www.hmailserver.com/ to download and install the latest build. Run through the installation steps, installing both the server and the admin console, configuring it for a localhost instance, picking a password, and getting it running. Personally, I had nothing to configure in Windows Firewall, but if you do, allow it through.

Once it's installed, open up the admin console to configure it. One of the keys here is we're barely going to configure it to do anything. In fact, we're going to limit what it can do.

First, do not set up a domain.

Expand Settings, select Protocols. Only select SMTP (deselect the other protocols).

upload_2017-4-11_23-46-9.png


Under Protocols > SMTP, select the "Delivery of e-mail" tab. Steps below, also reflected in the screenshot.

upload_2017-4-11_23-47-51.png

  • Under "Delivery of Email":
    • Set the "Local host name" setting to "localhost"
    • Consider changing the number of tries and frequency of retries. Occasionally there are hiccups (like you're on an unstable WiFi connection) and the defaults will wait another 60 minutes before retry. You can always enable logging in "Status" and check the queue for problems.
  • Under "SMTP Relayer":
    • Enter your SMTP host name and port number. In the screenshot above, you can see I used Gmail and its SSL port, which requires authentication.
    • You're most likely going to have to provide a user name and password (and using an account/server that does helps avoid you being flagged as a spam server), so select "Server requires authentication" and provide your user name (most likely your email address) and password.
    • Select the appropriate connection security method. Again, I'm using Gmail SSL, so that's what I've selected.
I left the rest of the SMTP settings at their defaults, though you may want to look at the "RFC compliance" tab. I have "Allow plain text authentication" disabled, and that probably matters if you're using SSL/TLS. You can configure the other settings as necessary, though keep track of what you toggle in case it causes turns to not send.

Next, go to Advanced > IP Ranges

upload_2017-4-11_23-56-4.png

  • Delete everything except "My Computer"
    • This is key. We don't want emails originating from anywhere other than inside the machine. This helps protect your machine from external attacks and getting your IP and machine blacklisted as a spam server.
  • Edit "My Computer"
    • Make sure the IP range is exactly 127.0.0.1 for each
    • Uncheck POP3 and IMAP
    • Uncheck all boxes under "Require SMTP authentication"
      • This deals with authentication from apps sending from inside your computer, like Civ 4, not with your external email provider. We configured that earlier.
    • I believe you can uncheck "External to..." under "Allow deliveries from" but I can't remember if I had problems with that.
upload_2017-4-11_23-59-32.png


That's the end of configuring hMailServer. We're now going to try and send a game through it, so this is a fine time to go back to Status in the admin panel and enabling logging temporarily.

Civ 4
This is the really easy part. When you create a game, or if you're in one, set up the email and SMTP settings for each player (or the next player, for in game changes).

For each player, the SMTP server becomes "localhost". Enter their email address, or potentially, if there's a tracker you can send turns to, put that address in. I've only done the former.

At the end of a turn, send it. In general, you should see two things in the in-game log. One is that the turn was saved, the other that it was sent successfully. If it wasn't sent successfully, check your logs in hMailServer. Feel free to post issues here and I'll help as I can.

Hope this is useful to the people here in this community, or those searching for help with PBEM on the internet somewhere.

- omeganot
 

Attachments

  • upload_2017-4-11_23-59-23.png
    upload_2017-4-11_23-59-23.png
    489.7 KB · Views: 244
Top Bottom