Here's a Perl module that can be used to test an email relay:
Apparently this module sets up a line of communication with a mail server. Once that line of communication has been established, it is possible to test that the mail server is able and willing to relay email.
I'm going to guess that there are many mail servers that are only willing to relay email that comes from localhost. Therefore, the Net::SMTP module would need to reside on the same physical box as the mail server itself. This is pure guesswork on my part.
If your perl script and Net::SMTP are both on the same physical box, then this line:
$server = 'localhost';
or this line:
$server = '127.0.0.1';
should work.
If not relaying email from the same host as the mail server itself, I'm going to guess that you will need a username and password to access the mail server. This may be difficult or impossible to obtain if you are working with a shared web hosting company.
The good news is that you may not need a username and password for your mail server if Perl is also installed on the same server. Specifically, if Net::SMTP and your mail server share the same localhost address, then it may be possible to communicate with the mail server by running a cgi-bin perl script from a web browser.
I find this web page extremely helpful for testing a mail relay via a web browser:
Mail relay testing with a perl script
By following the suggestions in the above web page, I was able to test the mail server at the hosting company via my browser. I used the script suggested in the above link to convince the hosting company they need to authorize the email address that I wanted to relay email to.
All this to get a simple FormMail.pl script working. I was testing the mail server to make sure it would relay a form filled in from a web page. It would not.
The above web page gave me a script, and a 500 level mail server error message, to prove that the web hosting company was not relaying emails to email addresses not on the approved list. The email address I needed to relay email to was not on the approved list.
It took a couple of weeks, but the hosting company has come through and has approved two email addresses for relay --- one email address is for testing purposes and the other email address is the client's email address that will ultimately receive the form.
I wrote about this experience here:
IIS and FormMail.pl and Perl Taint Mode and Email Relay
Ed Abbott
No comments:
Post a Comment