locked
Email Relay issue--confirm surmise? RRS feed

  • Question

  • I'm pretty sure that I know what this is about, but I thought I'd run it by here to see if anyone could confirm or refute.

    For the first time in a couple of years or so I'm working with a client on an Apache server, so I'm dealing with php for the first time in a while. No problem. I hadn't installed php since this machine was built about 18 months ago, so I downloaded php 5.2.6 and installed and configured it, then configured it in EW.

    As a refresher, I downloaded Chris's (Veign's) simple php mail form and put the files into a practice Web I keep laying around, then modified the necessary lines in the script (basically "To" and "Subject") and ran the page. Everything went as expected, clicked "Send Email," and got the Thank You page. Only problem is, I had a server error message at the top of the page, to wit

    Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Unable to relay for [my email address here] in I:\My Documents\My Web Sites\Practice\public_html\email-thankyou.php on line 20

    Now, as it happens, I've seen this message before, under somewhat different circumstances. Not the whole message, because this one was generated by my server, but the "unable to relay" part. My ISP, like many residential customer ISPs nowadays, forbids email relays through its servers as an anti-spam measure.

    When I encountered this before, it was because I had set up one of my Outlook Express email accounts to use the POP3/SMTP servers provided by my account at my hosting provider. POP3 worked fine (no exploits available there, of course), but when I tried to send anything from that account I got the same error in the OE send/receive dialog.

    I called tech support (live American humans) and asked them about it, and they said, "Nah, baby, nah, cain't do dat." Well, words to that effect, anyway. The explanation was that open email relays were begging for spammers to exploit them. Makes sense.

    So, in that instance I was going through their system to get to another SMTP server, while in this instance my SMTP server was going through their system. I'm guessing that an email relay is an email relay no matter which direction it's coming from, and I'm just not going to be able to test an email form script's send function from my home account, unless I can configure a way to use their (my ISP's) SMTP server (which, BTW, is what I did in the case above, configuring OE to use my host's POP3 to receive and my ISP's SMTP to send, so I could receive and reply to mail sent to my Web site's domain).

    OK, so is my surmise correct, or has anybody got any other ideas as to what might be causing this? Not a show-stopper, since I can test from a dead page on the client's server if necessary, I suppose. Just curious if there's another likely reason for this symptom.

    cheers,
    scott

    Friday, September 26, 2008 7:23 AM

Answers

  • Check the domain in the "from" email address against the domain of the SMTP server. If they are not the same, the server will suspect a relay.

    HTH
    Kevin Spencer, Chicken Salad Alchemist
    Friday, September 26, 2008 10:16 AM

All replies

  • Check the domain in the "from" email address against the domain of the SMTP server. If they are not the same, the server will suspect a relay.

    HTH
    Kevin Spencer, Chicken Salad Alchemist
    Friday, September 26, 2008 10:16 AM
  • Adding to Kevin. 

    I would also check out the web hosts FAQ on sending email from PHP.  They may have some special setting that must be included in the php.ini file (usually set by them).  This would happen when a web hosts allows you to override the PHP.ini files with a local version stored in your web root folder.

    --
    Chris Hanscom - Microsoft MVP
    Resource Center | Veign's Blog | Web Development Help
    Friday, September 26, 2008 1:35 PM
  • <RANT>

    Actually your ISP is an idiot since that is a common myth that blocking port 25 will prevent spamming. It is one of those things that makes it look like they are doing something to prevent spam but in reality doesn't do anything but make it more inconvient. Some of the newer viruses that send out spam from infected machines contain a very lightweight smtp server that uses a port other than 25. Heck, I don't use port 25 on any of the domains I set up for clients just because of this port blocking.

    The reason it is BS is because if you look at what they tell you to do is to set the sender as being the same as an email account on their system and then to set the reply to in your email client to whatever address you want people to think it was sent from. That is what they told my clients who had port 25 blocked on their business class DSL. Instead, we told them to remove the block. I also found out from the web host what alternative SMTP port they used and instructed my clients to set up their accounts to use that port. Since we decided to get out of the hosting business a couple of years ago I have clients on approximately 15 different hosting companies, each and every one of them offers an alternative port, find out what you host uses and use it.

    BTW, most ISPs for broadband services will unblock port 25 if you call them and ask or if you use their online form. Orignally, SBC for example only blocked residential customer but a couple of years ago they started blocking even business customers - a witch for businesses that don't host their websites with SBC-Yahoo <shutter>.

    </RANT>

    MS MVP Expression http://by-expression.com
    Friday, September 26, 2008 3:05 PM
  • Hmm, well now. Now I'm not sure what to think. This morning I decided to do some basic ground-up testing. Started with the <? phpinfo(); ?> test. No problem, got the extensive info page.

    So, then, I created a "php-test" folder inside my practice Web, copied the four files from Chris's simple contact form example there, modified the php file to point to my primary email address and have an appropriate subject line, then tested. Hmm, no server error this time. The thank-you page appears, and to all appearances everything is copacetic.

    Only one problem--no email in my Inbox. I ran the test a half-dozen times, using To: addresses from three different domains, and no exceptions are thrown, but I never receive anything in any of my Inboxes.

    Like I said, it's been a while since I dealt with php. Any ideas or suggestions on where to begin
    troubleshooting this issue?

    [EDIT: OK, futher information. After successfully testing a bunch of scripts that did not involve emailing, and which worked fine, it became clear that php itself was working on my machine. I decided to test online. So I uploaded the files to a provider, opened a browser and browsed to the location of Chris's email form page, filled in the form and mailed it. Sure 'nough, right there in my Inbox, and right away, as well.

    So, no problem with the script (not that I thought there was), and it works fine from my provider's server, so clearly the issue is with my setup or configuration. Problem is, there are no exceptions being thrown and no indication that the email was not actually sent. I'm accustomed to having available a debugger, with trace, watch, breakpoints, etc. That's not available in this context.

    As I've mentioned several times on the forum, I freely admit that I'm not a php developer. I am hoping that some of you php gurus out there can just point me in a direction (or several directions ;-) to start looking to troubleshoot this issue. In the meantime, I'll just continue to do my development and testing for this page remotely, so I'm not dead in the water and there is no particular urgency. I just hate it when something like this happens and I can't figure it out. ;-)]

    cheers,
    scott
    • Edited by paladyn Friday, September 26, 2008 6:33 PM
    Friday, September 26, 2008 4:44 PM
  • Scott,

    Are you using the Cassini development server that ships with Expression Web or the full IIS install with a virtual directory? I don't think the Cassini server support smtp but IIS does when you properly configure it.
    MS MVP Expression http://by-expression.com
    Friday, September 26, 2008 6:37 PM
  • Cheryl D Wise said:

    Scott,

    Are you using the Cassini development server that ships with Expression Web or the full IIS install with a virtual directory? I don't think the Cassini server support smtp but IIS does when you properly configure it.


    MS MVP Expression http://by-expression.com


    Hmm, thank you, Cheryl! Although I was wondering last night, while php was going through its setup, whether smtp would work with EW's dev server, that completely slipped my mind when this issue began. Supposedly, the php msi installer configured IIS for the extensions and extras I chose to install, which included basically the ones suggested in EW's Help file (wish more folks would read that thing). I'll bet you've hit the nail right on the head.

    I'm in the middle of making a small change to the site I'm working on, at the client's request, but this afternoon I'll move a copy of the site into inetpub/wwwroot and test it with IIS. In all likelihood, that will resolve the issue (and satisfy my curiosity ;-). I'll let you know the results. And, thanks again!

    cheers,
    scott
    Friday, September 26, 2008 7:04 PM
  • Cheryl D Wise said:

    Scott,

    Are you using the Cassini development server that ships with Expression Web or the full IIS install with a virtual directory? I don't think the Cassini server support smtp but IIS does when you properly configure it.


    MS MVP Expression http://by-expression.com



    Confirmed! I moved a copy of the files into wwwroot, then opened the page from localhost and tested it. This time I got the 550 5.7.1 error for no relay allowed. That means it got as far as my ISP's SMTP server before it was rejected, and satisfies me that your surmise concerning the dev server is correct.

    So, basically I can't test SMTP from here, but no biggie. I can always test those pages remotely on my provider's server. But, at least my curiosity is satisfied now, and I can go forward without this issue nagging at me wanting a resolution. I hate it when that happens. Thanks bunches, Cheryl! ;-)

    cheers,
    scott
    Friday, September 26, 2008 7:35 PM
  • Scott, check your hosts KB articles to see if they have another port open for direct SMTP. I host most of my stuff on CrystalTech and they have another SMTP port open so that users can bypass the port blocking by ISPs (also comes in handy when I want to send larger than 10 MB files out, nice by-product). Sometimes it's not well documented up front at a web host but buried in some obtuse KB article.
    Friday, September 26, 2008 8:29 PM
  • And sometimes you have to actually send a message, call tech support or live chat to get the alternative port but every web host I've used (or my clients have used) has had at least one alternate smtp port. In most cases where secure smtp is offered that too will by-pass the lame port 25 block.
    MS MVP Expression http://by-expression.com
    Friday, September 26, 2008 8:40 PM
  • Mark, Cheryl, thanks for the information and advice. This being the end of the work week for normal mortals, I'll probably wait till their full-time staff (with the Tier 2 and Tier 3 guys who actually know what's going on, and have the power to fulfill) is back at work. I'll let you know what I find out when I talk to them.

    cheers,
    scott

    Friday, September 26, 2008 9:46 PM