PHP Mail Function not working |
|
When I execute the following test script:
<?php error_reporting(E_ALL); $to = 'WyleySam@comcast.net'; $subject = 'Testmail'; $message = 'Hello. This is a test.'; $headers = 'From: John Doe <john.doe@example.com>'; $RetVal = mail($to, $subject, $message, $headers); Echo $RetVal ?> I get the following error: SMTP server response: 550 5.1.0 Authentication required My php.ini file looks like: [mail function] ; For Win32 only. ;smtp_port = 465 smtp_port = 587 ; For Win32 only. sendmail_from = WyleySam@comcast.net ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). ;sendmail_path = Can any one please help??? |
||||||||||||
|
|
Thank you for your response.
I was under the impression that PHPEd was self contained. It has it's own server & MySQL. The code I supplied above works in Dreamweaver & when run from my localhost. It does not run when using PHPEd which is why I posted here and not someplace else. |
||||||||||||
|
Guru master
|
PhpED comes with a PHP server called SRV. It is not a web server, but it is full PHP and does everything any other PHP should do. Just like any other PHP, it might need configuring for some things and it has its own php.ini and modules. PhpED does not come with a special version of PHP, it is normal PHP.
Whilst SRV is capable of running some web projects, there are differences between SRV and a web server (eg Apache) that may mean it is better to use a real web server. Some would say that SRV is better for CLI projects. Irrelevant of which PHP you are using, nothing changes the fact that PHP mail() cannot authenticate to an SMTP server. Your port 587 is on some SMTP server which I assume is localhost (although 587 on localhost is unusual) and is not allowing you to connect. The error response 550 is originally from an SMTP server, it is not from PhpED or PHP. If a mail server is being used and it configured to relay for either a fixed IP address or 127.0.0.1, then the SMTP connection from PHP probably needs to use the same address as the relay. If the relay is set to 127.0.0.1, which is common, then your PHP is connecting using a fixed IP address, that would probably be enough to cause authentication failure. Is Dreamweaver running the PHP code directly, or is it running the code through a PHP server? I stopped using Dreamweaver for PHP development years ago, but it didn't use to run PHP itself, it used to require a server, just like PhpED. Is Dreamweaver running through a PHP server that is configured so it can email? Maybe you can tell PhpED to use the same server? PhpED does not come with MySQL. It does come with some MySQL integration and profiling capabilities, but you need to install MySQL yourself, or use a XAMPP/WAMP distribution. |
||||||||||||
|
|
I use the XAMPP package to set up my localhost and PHP is running through it. I am retired now and only have a few customers left which is why I still use Dreamweaver. I use Windows Live Mail as my mail client.
This is all started when I was unable to send email using Dreamweaver & directly from my a php file on my localhost (XAMPP). I contacted Comcast and they told me to change the port from 465, which used to work fine, to 587. After doing that I was able to send EMail using Dreamweaver & from my local host. I'm still don't understand how I can send email from Dreamweaver & from my localhost but not from within PHPEd. Since you say the the 550 error comes from the SMPT server I guess I'll contact Comcast again. Thanks for your help. |
||||||||||||
|
Guru master
|
So does that mean PhpED is using NuSphere SRV or is it using your XAMPP server?
If PhpED is also using your XAMPP server (use phpinfo to check) then you should find email sending works the same as when you are using Dreamweaver. The php.ini snippet that you showed does not include an SMTP server, which means it is probably defaulting to localhost and not Comcast. You possibly need an SMTP setting:
Some service providers do not require authentication for sending email under specific conditions, such as when you have a internet connection direct to them. |
||||||||||||||
|
|
I must be running from the NuSphere SRV server and not my localhost because when testing I disabled my localhost.
I added SMTP = smtp.comcast.net to all php.ini files in the PHPEd folder - still am getting same error. Does sendmail_path have a value to it??? If so do you know what it is??? The sendmail_path in the XAMPP php.ini points to "\"C:\XAMPP\sendmail\sendmail.exe\" -t", but I have no idea what mail program PHPED uses. XAMPP has commented out http://php.net/sendmail-path. I'll try that on Monday. I'm taking a day off on Sunday. Once again thanks for all your help. |
||||||||||||
|
Guru master
|
Normally Windows PHP does not use the sendmail settings in php.ini and it ignores those settings. There is a way of getting Windows PHP to use sendmail settings, which means even on Windows you can use a sendmail replacement. That C:\XAMPP\sendmail\sendmail.exe looks like your XAMPP is using a sendmail replacement.
The SMTP settings for sendmail.exe may be passed in on the command line (the bit where the -t is) or by a configuration elsewhere, maybe even in php.ini PhpED does not use a mail sender because it simply provides you with a ready to go PHP server called SRV. You may still have to configure that PHP server if you want to use it with certain features. The NuSphere SRV server does not come with a sendmail replacement, although your XAMPP sendmail replacement would likely work with it, but you will have to configure it. At the moment SRV is missing those sendmail settings and attempting to use SMTP. If you are using the sendmail replacement that I am thinking of, those SMTP settings are in c:\xampp\sendmail\sendmail.ini but SRV is not attempting to use the sendmail replacement. My recommendation is to use your XAMPP server with PhpED - for web development the majority of PhpED developers either use XAMPP, or IIS with PHP. I use a variety of development IDE's other than PhpED and in my case I have a few XAMPP and real Linux servers for different versions of things. I use those servers for all web projects and only use NuSphere SRV with PHP CLI projects. Irrelevant of the IDE, all of the XAMPP servers behave consistently; PhpED and other IDEs do not have any impact on how those servers work. |
||||||||||||
|
|
I have no idea how to use the XAMPP server with PhpED.
I've added SMTP = smtp.comcast.net to the php.ini Comcast cannot help. According to them since I can send/receive email thru Windows Live Mail there is nothing they can do. I read somewhere on the internet that PEAR should me installed - it wasn't. There is no PEAR directory in D:\Development\PHPEd\php54, which is the directory the php.ini file is in. PEAR is now installed in C:\Users\NeilSwartz\AppData\Roaming\PEAR. I know nothing about PEAR!!! The registry entries for PEAR are: "PHP_PEAR_SYSCONF_DIR"="C:\Users\NeilSwartz\AppData\Roaming\PEAR" "PHP_PEAR_INSTALL_DIR"="C:\Users\NeilSwartz\AppData\Roaming\PEAR\pear" "PHP_PEAR_DOC_DIR"="C:\Users\NeilSwartz\AppData\Roaming\PEAR\docs" "PHP_PEAR_BIN_DIR"="C:\Users\NeilSwartz\AppData\Roaming\PEAR" "PHP_PEAR_DATA_DIR"="C:\Users\NeilSwartz\AppData\Roaming\PEAR\data" "PHP_PEAR_PHP_BIN"="D:\Development\PHPEd\php54\php.exe" "PHP_PEAR_TEST_DIR"="C:\Users\NeilSwartz\AppData\Roaming\PEAR\tests" Still getting the same error: Warning: mail(): SMTP server response: 550 5.1.0 Authentication required. |
||||||||||||
|
Guru master
|
You don't need to know anything about PEAR - I don't think you need PEAR. I've never used PEAR for sending email; there are better methods. I believe some (or all) of the PEAR packages are no longer maintained. Many of them will still work with newer PHP.
I've already mentioned this previously, but I'll be a little more consise here: * It looks like your existing XAMPP is using a sendmail replacement; it is not using the SMTP settings in php.ini * Your sendmail replacement probably gets it SMTP settings from c:\xampp\sendmail\sendmail.ini - it does not get its SMTP settings from php.ini * With PhpED, you are trying to use the built-in web server SRV with SMTP settings from php.ini - it is probably not going to work and if the comcast email server requires authentication (username & password) it might even be totally incapable of working using php.ini SMTP settings. * My recommendation is to use your XAMPP with PhpED. The PhpED project wizard asks a few questions so it understands where the web site files are stored on disk and which web server you are using. If you are using a local XAMPP then that is the Local server option. If your XAMPP server is running, then you can access web sites using a URL such as http://localhost/mywebsite For an existing project, all you have to do is tell PhpED what that URL is, using the Project Properties > Run Target. In those settings you will set the Run target to Local server, then set the web site address in Root URL. In your case it might be something like http://localhost/mywebsite If you are wanting to run whichever file is currently open in the PhpED editor, then leave the Default file or URL blank. If the web site is capable of running through your XAMPP, then it will work with PhpED. Debugging is another step, you have to installed the NuSphere debugger DBG into your XAMPP, but getting the site running would be the first step. You can use the NuSphere Debugger Wizard to assist with installing DBG into your XAMPP. http://www.nusphere.com/products/dbg_wizard_download.htm |
||||||||||||
|
|
I went to http://www.nusphere.com/products/dbg_wizard_download.htm and pressed the Download Now button. The screen displayed text when I did a Save As it saved the text to a file named dbg-wizard_php.mht (have no idea what a mht file is). I moved the file to my localhost root dir (http://localhost/) and tied to execute it as mht & after changing the extension to php. All I got was text displayed on the screen.
I have no idea what is going on. I am a beginning PHP programmer and some of this stuff is greek to me!!! All I know is everything worked correctly 6 months ago when I last used PHPEd. I've also copied to problem php script to several websites on the lan and it worked correctly. Once again thanks for trying to help. You must be frustrated with me. |
||||||||||||
|
Guru master
|
Don't save the file as an MHT because that is an archive format for Internet Explorer, it does not the original text for the PHP file. When you later rename the file to PHP, the file still has incorrect contents because it has already been converted to MHT.
Go back to the download page, click Download File, do a Save As and use Text File. That should give you the original unmodified file. Maybe last time you used PhpED, you used it with a XAMPP server? This time on your 3-May reply you hinted you were using PhpED with SRV and that would be the default if you had just installed PhpED. If you're script emails correctly through your XAMPP server, then using your XAMPP server with PhpED will also email correctly. |
||||||||||||
|
PHP Mail Function not working |
|
||
Content © NuSphere Corp., PHP IDE team
Powered by phpBB © phpBB Group, Design by phpBBStyles.com | Styles Database.
Powered by
Powered by phpBB © phpBB Group, Design by phpBBStyles.com | Styles Database.
Powered by