[PHP] mail() + localhost
PHP'ers, I am sure this would have been asked a zillion times but I take this as my turn to get some help. I hate to ask such rhetorical questions but quite couldn't understand how to tweak this. All I am trying to do is send a mail from my localhost to my Gmail ID. I read stuff about how the SMTP port should be accessible; should be open et al. My set-up is very simple: 1. Using Easy PHP. 2. Windows XP Also, when the comment says that you need to 'configure' your php.ini, which .ini should I modify? The reason being, I see that file in two locations, apparently. (i) C:\Program Files\EasyPHP 3.0\apache (ii) C:\Program Files\EasyPHP 3.0\conf_files *My php.ini (will remove the semi-colon)* * * ; For Win32 only. ;SMTP = localhost ;smtp_port = 25 ; For Win32 only. ;sendmail_from = m...@example.com *My code: * * * * ?php * $from= shreya...@gmail.com; $to =shreya...@gmail.com; $subject = PHP Testing; $message = Test Me; mail ($to,$subject,$message,'From:'.$from); ? * * * Regards, *Shreyas Agasthya
Re: [PHP] mail() + localhost
On Thu, Jul 1, 2010 at 9:09 AM, Shreyas Agasthya shreya...@gmail.com wrote: Also, when the comment says that you need to 'configure' your php.ini, which .ini should I modify? The reason being, I see that file in two locations, apparently. (i) C:\Program Files\EasyPHP 3.0\apache (ii) C:\Program Files\EasyPHP 3.0\conf_files Call this in a script running under your web server: http://www.php.net/phpinfo Alternatively, you could also look at these: http://www.php.net/php-ini-loaded-file http://www.php.net/php-ini-scanned-files Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mail() + localhost
On Thu, Jul 1, 2010 at 09:09, Shreyas Agasthya shreya...@gmail.com wrote: All I am trying to do is send a mail from my localhost to my Gmail ID. I read stuff about how the SMTP port should be accessible; should be open et al. My set-up is very simple: 1. Using Easy PHP. 2. Windows XP 3.) An SMTP server, I hope...? Also, when the comment says that you need to 'configure' your php.ini, which .ini should I modify? The reason being, I see that file in two locations, apparently. (i) C:\Program Files\EasyPHP 3.0\apache (ii) C:\Program Files\EasyPHP 3.0\conf_files In a browser, check the output of phpinfo() - specifically, the value for Loaded Configuration File - and modify that, as the other may be for the PHP CLI, another installed component using a local override, or may not even be used at all. *My php.ini (will remove the semi-colon)* * * ; For Win32 only. ;SMTP = localhost ;smtp_port = 25 Uncomment the two lines above. ; For Win32 only. ;sendmail_from = m...@example.com You don't *need* to uncomment and set the `sendmail_from` option, as long as you set an explicit `From` header in your code. More on that after your snippet. *My code: * * * * ?php * $from= shreya...@gmail.com; $to =shreya...@gmail.com; $subject = PHP Testing; $message = Test Me; mail ($to,$subject,$message,'From:'.$from); ? Your code should be modified just a bit for better conformance and portability, but I understand that you're just using it as a test. After following the suggestions above (and remembering to restart Apache, of course), try this: ?php $from = sherya...@gmail.com; // Gmail allows (\+[a-z0-9\.\-_]+) appended to your username to filter emails in your Gmail box. $to = shreyasbr+phpt...@gmail.com; // This will append (at the moment, my local time) 1 Jul 2010, 09:27:23 $subject = PHP Testing .date(j M Y, H:i:s); $message = Test Me.; // Create your headers, remembering to terminate each line with CRLF (\r\n) to comply with RFC [2]821. $headers = From: .$from.\r\n; $headers .= X-Mailer: PHP/.phpversion().\r\n; // Send it, or inform us of an error. No need to use a -f flag here. if (!mail($to,$subject,$body,$headers)) { echo Ah, crap. Something's SNAFU'd here.; exit(-1); } ? -- /Daniel P. Brown UNADVERTISED DEDICATED SERVER SPECIALS SAME-DAY SETUP Just ask me what we're offering today! daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mail() + localhost
Erm... understood. I modified the changes to look like this in the php.ini file (the right one based on the output of phpinfo()). 3) *smtp = smtp.gmail.com* *smtp_port = 587* * * *I get : Failed to connect to mailserver at localhost port 587, verify your SMTP and smtp_port setting in php.ini* * * Regards, Shreyas On Thu, Jul 1, 2010 at 7:03 PM, Daniel Brown danbr...@php.net wrote: On Thu, Jul 1, 2010 at 09:09, Shreyas Agasthya shreya...@gmail.com wrote: All I am trying to do is send a mail from my localhost to my Gmail ID. I read stuff about how the SMTP port should be accessible; should be open et al. My set-up is very simple: 1. Using Easy PHP. 2. Windows XP 3.) An SMTP server, I hope...? Also, when the comment says that you need to 'configure' your php.ini, which .ini should I modify? The reason being, I see that file in two locations, apparently. (i) C:\Program Files\EasyPHP 3.0\apache (ii) C:\Program Files\EasyPHP 3.0\conf_files In a browser, check the output of phpinfo() - specifically, the value for Loaded Configuration File - and modify that, as the other may be for the PHP CLI, another installed component using a local override, or may not even be used at all. *My php.ini (will remove the semi-colon)* * * ; For Win32 only. ;SMTP = localhost ;smtp_port = 25 Uncomment the two lines above. ; For Win32 only. ;sendmail_from = m...@example.com You don't *need* to uncomment and set the `sendmail_from` option, as long as you set an explicit `From` header in your code. More on that after your snippet. *My code: * * * * ?php * $from= shreya...@gmail.com; $to =shreya...@gmail.com; $subject = PHP Testing; $message = Test Me; mail ($to,$subject,$message,'From:'.$from); ? Your code should be modified just a bit for better conformance and portability, but I understand that you're just using it as a test. After following the suggestions above (and remembering to restart Apache, of course), try this: ?php $from = sherya...@gmail.com; // Gmail allows (\+[a-z0-9\.\-_]+) appended to your username to filter emails in your Gmail box. $to = shreyasbr+phpt...@gmail.com shreyasbr%2bphpt...@gmail.com; // This will append (at the moment, my local time) 1 Jul 2010, 09:27:23 $subject = PHP Testing .date(j M Y, H:i:s); $message = Test Me.; // Create your headers, remembering to terminate each line with CRLF (\r\n) to comply with RFC [2]821. $headers = From: .$from.\r\n; $headers .= X-Mailer: PHP/.phpversion().\r\n; // Send it, or inform us of an error. No need to use a -f flag here. if (!mail($to,$subject,$body,$headers)) { echo Ah, crap. Something's SNAFU'd here.; exit(-1); } ? -- /Daniel P. Brown UNADVERTISED DEDICATED SERVER SPECIALS SAME-DAY SETUP Just ask me what we're offering today! daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ -- Regards, Shreyas Agasthya
Re: [PHP] mail() + localhost
Spoke too fast. Fixed that (SMTP has to be uppercase) Now it is : *SMTP server response: 530 5.7.0 Must issue a STARTTLS command first. c15sm7128213rvi.11* On Thu, Jul 1, 2010 at 7:25 PM, Shreyas Agasthya shreya...@gmail.comwrote: Erm... understood. I modified the changes to look like this in the php.ini file (the right one based on the output of phpinfo()). 3) *smtp = smtp.gmail.com* *smtp_port = 587* * * *I get : Failed to connect to mailserver at localhost port 587, verify your SMTP and smtp_port setting in php.ini* * * Regards, Shreyas On Thu, Jul 1, 2010 at 7:03 PM, Daniel Brown danbr...@php.net wrote: On Thu, Jul 1, 2010 at 09:09, Shreyas Agasthya shreya...@gmail.com wrote: All I am trying to do is send a mail from my localhost to my Gmail ID. I read stuff about how the SMTP port should be accessible; should be open et al. My set-up is very simple: 1. Using Easy PHP. 2. Windows XP 3.) An SMTP server, I hope...? Also, when the comment says that you need to 'configure' your php.ini, which .ini should I modify? The reason being, I see that file in two locations, apparently. (i) C:\Program Files\EasyPHP 3.0\apache (ii) C:\Program Files\EasyPHP 3.0\conf_files In a browser, check the output of phpinfo() - specifically, the value for Loaded Configuration File - and modify that, as the other may be for the PHP CLI, another installed component using a local override, or may not even be used at all. *My php.ini (will remove the semi-colon)* * * ; For Win32 only. ;SMTP = localhost ;smtp_port = 25 Uncomment the two lines above. ; For Win32 only. ;sendmail_from = m...@example.com You don't *need* to uncomment and set the `sendmail_from` option, as long as you set an explicit `From` header in your code. More on that after your snippet. *My code: * * * * ?php * $from= shreya...@gmail.com; $to =shreya...@gmail.com; $subject = PHP Testing; $message = Test Me; mail ($to,$subject,$message,'From:'.$from); ? Your code should be modified just a bit for better conformance and portability, but I understand that you're just using it as a test. After following the suggestions above (and remembering to restart Apache, of course), try this: ?php $from = sherya...@gmail.com; // Gmail allows (\+[a-z0-9\.\-_]+) appended to your username to filter emails in your Gmail box. $to = shreyasbr+phpt...@gmail.com shreyasbr%2bphpt...@gmail.com; // This will append (at the moment, my local time) 1 Jul 2010, 09:27:23 $subject = PHP Testing .date(j M Y, H:i:s); $message = Test Me.; // Create your headers, remembering to terminate each line with CRLF (\r\n) to comply with RFC [2]821. $headers = From: .$from.\r\n; $headers .= X-Mailer: PHP/.phpversion().\r\n; // Send it, or inform us of an error. No need to use a -f flag here. if (!mail($to,$subject,$body,$headers)) { echo Ah, crap. Something's SNAFU'd here.; exit(-1); } ? -- /Daniel P. Brown UNADVERTISED DEDICATED SERVER SPECIALS SAME-DAY SETUP Just ask me what we're offering today! daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ -- Regards, Shreyas Agasthya -- Regards, Shreyas Agasthya
Re: [PHP] mail() + localhost
On Thu, Jul 1, 2010 at 10:02, Shreyas Agasthya shreya...@gmail.com wrote: Spoke too fast. Fixed that (SMTP has to be uppercase) Now it is : *SMTP server response: 530 5.7.0 Must issue a STARTTLS command first. c15sm7128213rvi.11* (Quick note: per the list guidelines, please don't top-post in threads.) That error message is because you're trying to connect to an SMTPS (secure, SSL-encrypted SMTP) server using plain text, which won't work. If you have a plain SMTP server running, try that to get one thing resolved at a time. Change the port to 25 in your php.ini (and, again, restart Apache) if plain SMTP is available on the default port. -- /Daniel P. Brown UNADVERTISED DEDICATED SERVER SPECIALS SAME-DAY SETUP Just ask me what we're offering today! daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mail() + localhost
Not sure where I am top-posting. I posted to my own mail so that one gets to know the latest. Nevertheless, I wouldn't go against the guidelines as I completely understand the havoc that it can create. The port is 587 as per Google; SMTP that I am using is Google's (anything wrong here?). If there is a rudimentary mistake that I am doing, please guide me. Regards, Shreyas On Thu, Jul 1, 2010 at 7:46 PM, Daniel Brown danbr...@php.net wrote: On Thu, Jul 1, 2010 at 10:02, Shreyas Agasthya shreya...@gmail.com wrote: Spoke too fast. Fixed that (SMTP has to be uppercase) Now it is : *SMTP server response: 530 5.7.0 Must issue a STARTTLS command first. c15sm7128213rvi.11* (Quick note: per the list guidelines, please don't top-post in threads.) That error message is because you're trying to connect to an SMTPS (secure, SSL-encrypted SMTP) server using plain text, which won't work. If you have a plain SMTP server running, try that to get one thing resolved at a time. Change the port to 25 in your php.ini (and, again, restart Apache) if plain SMTP is available on the default port. -- /Daniel P. Brown UNADVERTISED DEDICATED SERVER SPECIALS SAME-DAY SETUP Just ask me what we're offering today! daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ -- Regards, Shreyas Agasthya
Re: [PHP] mail() + localhost
Trying again; most likely I cannot do this without SSL. --Shreyas On Thu, Jul 1, 2010 at 8:42 PM, Shreyas Agasthya shreya...@gmail.comwrote: Not sure where I am top-posting. I posted to my own mail so that one gets to know the latest. Nevertheless, I wouldn't go against the guidelines as I completely understand the havoc that it can create. The port is 587 as per Google; SMTP that I am using is Google's (anything wrong here?). If there is a rudimentary mistake that I am doing, please guide me. Regards, Shreyas On Thu, Jul 1, 2010 at 7:46 PM, Daniel Brown danbr...@php.net wrote: On Thu, Jul 1, 2010 at 10:02, Shreyas Agasthya shreya...@gmail.com wrote: Spoke too fast. Fixed that (SMTP has to be uppercase) Now it is : *SMTP server response: 530 5.7.0 Must issue a STARTTLS command first. c15sm7128213rvi.11* (Quick note: per the list guidelines, please don't top-post in threads.) That error message is because you're trying to connect to an SMTPS (secure, SSL-encrypted SMTP) server using plain text, which won't work. If you have a plain SMTP server running, try that to get one thing resolved at a time. Change the port to 25 in your php.ini (and, again, restart Apache) if plain SMTP is available on the default port. -- /Daniel P. Brown UNADVERTISED DEDICATED SERVER SPECIALS SAME-DAY SETUP Just ask me what we're offering today! daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ -- Regards, Shreyas Agasthya -- Regards, Shreyas Agasthya