Blocked Port 25 Workaround

Recently, I switched to AT&T DSL. I’m quite happy with the price of $19.95/month. Of course, there was a drawback; they block port 25, the port used to send email. I figured that out after an hour of searching. There are a few solutions for this. Here are my findings.

Update: I use sendmail on a linux  server to run my email.

Solution 1: Change the listening port
This is the most obvious fix, and the one I implemented. You need to admin your own server to do this. Using sendmail, it’s only 2 lines in sendmail.mc:


define(`RELAY_MAILER_ARGS', `TCP $h 2525')dnl
define(`ESMTP_MAILER_ARGS', `TCP $h 25')dnl

The first line changes the smtp port to 2525, and the second line changes the outgoing smtp port back to 25. Without the second line, no email will go out.

Note: when editing the sendmail.mc, you need to compile it by running make or m4 sendmail.mc > sendmail.cf. After compiling it, restart the sendmail daemon. DO NOT EDIT sendmail.cf!

Solution 2: Use a proxy
There are plenty of services out there that will proxy, or relay, for a fee. I am sure there are proxies that are free, but I wouldn’t trust them to keep my information private for a second.

This solution doesn’t require you to have admin rights on the server and it is a lot easier. Each proxy setup is different, so follow the instructions they give.

Solution 3: Don’t send email with that account
Not the best solution, but you can get a yahoo or gmail account for free. You can still receive email from any account. This is probably not acceptible for most people.

Solution 4: Switch to another ISP
This is always an option, even if it means downgrading to dial-up. The only reason why I am keeping AT&T is because of the price.

Well, I hope that you found this information helpful. Happy e-Mailing.

Regular Expressions Part 2

In the previous post, simple regular expressions were explained. Today, regex becomes useful. If you didn’t read the previous post, you should at least skim it.

For this post, all examples will be using perl.

Getting a Match
Parentheses are used to extract a match from a string. Let’s say you want to know what is inside the “head” html tags, here’s the code:


if ( $html =~ m/(.*)<\/head>/is ) {
print "HTML Header:\n$1\n";
}

The match is given to the code as the variable $1. Note that this example has an “s” after the closing forward slash. The s treats the string to be compared as a single line. Without it, you probably wouldn’t get a match. Also, this simple regex will not match the entire head in all cases. If you put “</head>” inside a meta keyword list, it would match, but stop at the first “</head>”.

Here’s another example:


if ( $text =~ m/ a ([aeiou][a-z]+)/i ) {
print "Grammar error: use \"an\" when the following word starts with a vowel.\n i.e. an $1\n";
}

Yup, it’s a grammar rule check. Now you know where that green squiggly underline comes from.

Whitespace and Non-whitespace matching
Whitespace refers to a space, tab, and carriage returns. “\s” matches a whitespace character and “\S” matches a non-whitespace character.

That’s the basic of regular expressions. These magically expressions work in almost every language, including perl, php, javascript, and python.

Happy pattern matching.

Regular Expressions Part 1/2

Regular Expressions, those oddities that live between two forward slashes, are very powerful and quite mysterious. Staring at something like /([abcdef0123456789]+)/i all day can give you a heaadache. With a little luck and a bit of hard work, you’ll know exactly what the previous expression means.

For this post, all examples will be using Perl.

Text Search
A regular expression, or regex, in its simplest form is a text search. Here’s an example:


$var = "Hello World";
if ( $var =~ m/Hello/ ) {
print "Match\n";
}

In perl, the operator =~ is used to run a regex against a variable. The m/Hello/ will match if the variable has “Hello” anywhere.

To make the match case-insensitive, simply add an i after the last forward slash. So change the regex to m/Hello/i to match “Hello”, “HeLlO” and “hello”.

Carets and Dollar Signs
A caret (^) at the beginning of a regex represents the beginning of a string. Here’s an example:


$var = "Hello World";
if ( $var =~ m/^Hello/ ) {
print "Match\n";
}

A dollar sign ($) at the end of a regex represents the end of a string. Another example:


$var = "Hello World";
if ( $var =~ m/World$/ ) {
print "Match\n";
}

If you want to match one of these special characters, put a backslash before it.


$var = "Hello^ $World";
if ( $var =~ m/e\^ \$W/ ) {
print "Match\n";
}

Braces
Putting a list of characters inside braces “[]” will match any of these characters.


$var = "Hello World";
if ( $var =~ m/[aeiou]/ ) {
print "There is a vowel.\n";
}

You can even tell if a string contains a hexadecimal value. This example uses the special character +. It means that the previous character must appear 1 or more times.


$var = "0x157afde";
if ( $var =~ m/^0x[0123456789abcdef]+$/ ) {
print "It is hexadecimal\n";
}

Within the braces, instead of listing every possible character, you can specify a range to be matched. For instance, 0-9 will match any digit 0 through 9. Here’s a slightly shorter example:


$var = "0x157afde";
if ( $var =~ m/^0x[0-9a-f]+$/ ) {
print "It is hexadecimal\n";
}

The caret (^) continues its job as a special character within braces. Putting one at the beginning of the braces will match anything but those listed inside the braces.


$var = "0x157afde";
if ( $var =~ m/^[^0-9a-fx]+$/ ) {
print "It is not hexadecimal\n";
}

Periods and Asterisks
A period (.) will match any character.


$var = "Hello World";
if ( $var =~ m/^H.llo W.+$/ ) {
print "Match\n";
}

An asterisks (*) is similar to a plus sign (+), but an asterisks will match 0 or more of the previous character.


$var = "Hello World";
if ( $var =~ m/^Hello .*$/ ) {
print "Saying hello\n";
}

Tomorrow
Tomorrow, more special characters, including white-space characters, non-whitespace characters, and matching parentheses.

Internet Troubleshooting

What do you do when your internet connection goes does? Go get a board game or cards? Call your IT friend from work? Bang on the desk until the page loads? While most of these are good solutions, getting your connection running again is pretty simple. As long as nothing is wrong on your provider’s end, that is.

Perform each step by itself. Try to load a webpage after each step to see if it is working.

  1. Check your connections.
  2. Shutdown your computer and boot it up again.
  3. Unplug your router, if you have one, for 30 seconds then plug it back in.
  4. Unplug your cable/dsl modem for 30 seconds then plug it back in.
    Wait for the “Internet” or “DSL” or “Cable” light to light up.
  5. Repeat Step 3.
  6. Repeat Step 2.
  7. Open Control Panel -> Network Connections and Delete the “Local Area Connection”, then reboot.

If none of these steps fix your connection, there is probably a problem at your provider and you should call their tech support line.

Hint: Print this page and keep it by your computer so you have it when the internet does go out. Also, write the tech support number on the print out for convenience.

« Previous Page