I just spent the last 3 hours chasing my tail trying to figure out a install problem I was having with Drupal:

Symptom
When logging into Drupal for the VERY FIRST TIME (read, fresh install), the standard e-mail fails with the following error message:

"SMTP server response: 550 5.7.1 Unable to relay.."

This causes drupal to provide a temporary password within the same screen (rather than mailing it out) - when you try to navigate away from the screen there are missing menus (specifically the entire admin tree). Anyway, to solve the problem here is what I did to enable SMTP Relaying on my test machine:

1) Go to: start > settings > control panel > Administrative Tools > Internet Information Services
2) Expand the " (local computer)" node
3) Right click on your SMTP server > go to "Properties"
4) Click "Access" tab
5) Under Relay Restrictions, click the "Relay" button
6) Click "Add"
7) Select "Single Computer" and enter IP address 127.0.0.1
8) Hit OK, OK, OK (until the properties dialog is closed)

At this point it should work, but just to be extra sure, create a php page called SMTPtest.php and drop in the following code:

----------------

<?
$to = "youremailaddress@domian.com";
$subject = "test from localhost";
$msg = "I completely understand SMTP servers now!";
$headers = "From: localhost@localhost.com\nReply-To: localhost@localhost.com";
$config = "-stfu@noob.com";
mail("$to", "$subject", "$msg", "$headers", "$config");
echo "finished!";
?>

----------------

Once you have this file, drop it in your drupal root directory, then hit the page with a browser. If you see a "finished!" message, then check your inbox and you should have a test message sent from localhost. If you see anything resembling the relay message again, double-check your steps 1-8 (as described above) and try again.

Good luck!

Comments

Axman-1’s picture

I tried this solution and I was able to have the script send me one email, but the first test user failed to recieve the registration confirmation email. Things seemed to revert, though the settings had not changed.

One big difference is that my server has Exchange on it, in addition to IIS running, and the relay options are in the Exchange System Manager, not in IIS Manager. Otherwise, they should work the same, and they certainly look the same.

I'm so close to having everything work great. What gives?

For what it's worth, the very first user received the email just fine, it was simply all other users after that who registered through the website.

Nikkol’s picture

Thanks for the tip. I was having the same issue even though I had the server's actual IP in the Relay restrictions. I added the localhost IP as you suggested and mail sent just fine.


I take it back. It worked for sending me a forgot password email, but not for new registrations.

robdinardo’s picture

thank you calderson for the tip (and being explicit about it). It is nice to have people like you in this world.

nima2’s picture

calderson....thank you, thank you, thank you and....THANK YOU!

calito’s picture

THANK YOU FOR THE TIP, IS A REALLY GOOD WAY TO MAKE A BIG KNOWLEDGE COMUNITY. FOR ME WAS VERY USEFUL

sunila’s picture

code is still not working...
i hav done all this + changed the three lines of php.ini
i m confused about where to put this new php test page .. in wwwroot folder or mailroot.. ???
i tried both .. n it didnt work:(
$unila

stegy81’s picture

LOL......I like your sample email PHP code.....very nice ;) I had a brain fart and pulled this rookie maneuver too when setting up my relay as well.

fakhre’s picture

thanks a lot..

fakhre

paulmwiu’s picture

hi calderson,

Your information really helped me a lot.
Cheers and Thanks,

Paul Mwiu

chanderkhanna1’s picture

I am using WAMP and Windows Vista and having the same problem. Wonder if anyone has any ideas on how I may be able to fix it...already spent many hours on it....thanks!!!!

chander

brainHax’s picture

thanks dude , u saved my day , i been struggling with PostCast Server to configure it as a local email server , now its working ,

thanks again ,

redbull247365’s picture

Worked great thanks!!

hoobuba’s picture

Hello - thanks for the code and tip. Do you have any idea how the setting works on IIS 7 ? The email is send but the error appears ... Thanks for any help!

Milos

luf’s picture

At first creation of drupal server email with admin password had an error as well.
I set up this solution with the SMTP server when it was created BEFORE I received the error. I was still receiving Error could not send 500 - username @ domain.com mail.inc on line 193 -

*HERES HOW I FIXED THIS PROBLEM:*

Using: Windows Server 2008 + IIS 7 + MySQL 5.1 + PHP 5.2

HOW TO FIX THIS PROBLEM (Full Walkthrough for Dedicated Server Hosts w/ Remote Access Capabilities)
1. Enable SMTP Server through Server Management > Features > Add Feature
2. Open IIS 6 > Right Click Virtual SMTP Server > Properties > Access tab at top > Relay button on bottom > Add > 127.0.0.1
3. Go to your DrupalSite/sites/default/settings.php > Scroll down to PHP Settings where you see lots of ini_set('blabalbla'); lines
4. Add to the end of these lines

/* FOR SERVER HOSTS, DEDICATED, REMOTE ACCESS USERS */
ini_set ("SMTP","localhost");

5. Dont forget the trailing semicolon.
6. Create a User account on your drupal site, use your email address, and notify the user of the account.
7. Rest.

If you are not a dedicated remote access server host, you may attempt this fix by replacing step 4 "localhost" with "your.server.smtp.ip.address" .

Enjoy.

vodich01’s picture

I have done all this step. However, the mail couldn't reach. How can I do ?

commander_keen’s picture

Thanks a lot dude, would never have found out that by myself! :-)

disparil’s picture

Thank you very much!!