my SMTP settings are as follows:
[mail function]
; For Win32 only.
SMTP = localhost ; for Win32 only
sendmail_from= vwar@synapticshock.org ; for Win32 only
Im running IIS, not apache
Main Topics
Browse All Topicsi have this error and no clue why i do :(
Warning: mail(): SMTP server response: 501 5.5.4 Invalid Address in E:\synapticshock.org\vwar\
572: mail($row["email"],$subjec
any ideas?
if you need more info please let me know and ill provide it :)
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
CrYpTiC_MauleR
Q-do you have an SMTP server running on 'localhost' ?
A-yes
danceanthems
Q-try your mail function with the to and from coming from you. Also if you are on a company network try editing you SMTP address to be the same as your email server.
A-im not to familiar with phpmail, so forgive me if i cant understand. from and to,im unfamiliar with. the SMTP server address is also localhost :)
RQuadling
Q-What is the email address you are sending to in $row['email']? Is it valid?
A-all the email address are valid, they are coming from an mysql database, ive tested these via normal mail thru the smtp server, and the smtp server works
The behaviour of these functions is affected by settings in php.ini.
Name Default Changeable
SMTP "localhost" PHP_INI_ALL
smtp_port "25" PHP_INI_ALL
sendmail_from NULL PHP_INI_ALL
sendmail_path DEFAULT_SENDMAIL_PATH PHP_INI_SYSTEM
For more info about php.ini settings for mail function goto
http://us4.php.net/manual/
When I send email on a windows platform, I don't use a local SMTP server. Instead I send the email directly to the recipients server, just like an SMTP relay server.
Here is the code.
<?php
function sendMail($sEmailToSend, $sSubject, $sMessage, $sHeaders)
{
$sGatewayIP = '10.0.0.1';
preg_match("'\.*@(.*)'sim"
$sNSLookup = shell_exec("nslookup -q=mx {$aMatches[1]} {$sGatewayIP} 2>nul");
preg_match_all("'^.*MX preference = (\d{1,10}), mail exchanger = (.*)$'simU",$sNSLookup,$aM
ini_set('SMTP',$aMXMatches
return @mail($sEmailToSend, $sSubject, $sMessage, $sHeaders);
}
?>
The only piece of information I am unable to determine automatically is the Gateway IP.
What I did to find this initially is ...
tracert www.experts-exchage.com
And the first address in the list is my gateway, and as I am behind a gateway/proxy, this is the proxy server's address.
What this script does is :
1 - Extract the domain name for the recipient.
2 - Runs NSLookup (a windows console app) to get the MX (Mail exchanger) records.
3 - Extracts from the first MX record the mail server's address.
4 - Sets the SMTP ini setting to this server.
5 - Sends the message.
From what I can tell, this will work EXACTLY as if you had telnetted into the recipients server and sent them the email. And as far as I can tell, this is pretty much what happens when you send an email to your SMTP server which then sends it to their server.
So should always work.
Now, the sharp eyes amongst you may be thinking why am I not using the PHP function ...
getmxrr() -- Get MX records corresponding to a given Internet host name.
Well, because I am on Windows and ...
"Note: This function is not implemented on Windows platforms. Try the PEAR class Net_DNS."
And I've not yet used the PEAR class.
Hope this helps.
Richard.
it returned an email address, which is correct
but this is the error im getting atm
Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in
E:\synapticshock.org\vwar\
looks to me that php mail doesnt want to connect to the SMTP server
the SMTP server is on the same box (localhost) and its def port 25
Lets start again.
1 - What is the email address you are sending FROM:? Have you included the name as well as the email address?
2 - What is the email address you are sending TO:? Have you included the name as well as the email address?
3 - Do you have a local SMTP server capable of relaying email? NOTE: Relaying is where the server you are sending email to is NOT the server that the email will end up on. If I send an email from my desktop to a hotmail account via my exchange server, the email does not end up on the exchange server. The exchange server sends the mail to hotmail for me, or relays it. Normally relaying is disabled as the server can be used by anyone to send email to anyone without having direct permissions to do so (spamming).
4 - Does the email account you are sending TO: exist on the same server as the address you are sending FROM:
To recap.
On windows, there is no native method of sending email. You MUST use some external method. On Unix the program SENDMAIL exists and this deals with sending email.
The script I supplied is an extremely basic way of sending email to anyone on from a windows PHP installation.
The script does similar things to sendmail. It looks for the email server of the recipient you are sending email to and then configures PHP to use that email server.
You can simulate the entire script manually.
This will involve the use of a command prompt, ipconfig, telnet and nslookup.
First load a command prompt.
Then type in IPCONFIG /ALL
Look for the Default Gateway. This is the IP address you need to use for NSLOOKUP.
Then take the email address and remove everything upto and including the @, giving just the domain name.
e.g.
bob@btinternet.com becomes btinternet.com
Now, back at the command prompt ....
NSLOOKUP -q=MX btinternet.com default_gateway_address_he
On my server, I don't need to put the default_gateway_address, so I can just type ...
NSLOOKUP -q=MX btinternet.com
This results in ...
nslookup -q=mx btinternet.com
Server: mail.gateway.xxxxx <<<<<< NOTE (My local gateway)
Address: 10.0.0.xxx <<<< NOTE (My local gateway IP address)
Non-authoritative answer:
btinternet.com MX preference = 20, mail exchanger = mx1.bt.mail.yahoo.com
btinternet.com MX preference = 30, mail exchanger = mx2.bt.mail.yahoo.com
So. We now have the MX records. This is the bit that is important.
By setting the smtp server to mx1.bt.mail.yahoo.com, you can now use PHP mail() function to send email to bob@btinternet.com
BTInternet.com is now handled by Yahoo (in case you were interested).
Obviously, you can only send 1 email at a time. You MAY be able to package several emails to the same server in one hit. Not sure.
This, in principle, is what an SMTP relay is. It takes your email, works out where to send it and then sends it.
This method requires no additional software or servers.
So. Can you provide some code you are using and the EXACT AND COMPLETE email addresses you are using.
NOTE: If the SMTP server you are trying to send to requires authentication, I have not dealt with that. This would need to be handled in some other way.
Richard.
Business Accounts
Answer for Membership
by: CrYpTiC_MauleRPosted on 2004-07-27 at 04:09:34ID: 11645172
check your SMTP settings in your php.ini file and in your Apache config file. SMTP server is not correct it seems.