Re: mail() + localhost

From: Date: Thu, 01 Jul 2010 14:02:39 +0000
Subject: Re: mail() + localhost
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-306604@lists.php.net to get a copy of this message
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 <shreyasbr@gmail.com>wrote: > 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 <danbrown@php.net> wrote: > >> On Thu, Jul 1, 2010 at 09:09, Shreyas Agasthya <shreyasbr@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 = me@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= "shreyasbr@gmail.com"; >> > $to ="shreyasbr@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 = "sheryasbr@gmail.com"; >> >> // Gmail allows (\+[a-z0-9\.\-_]+) appended to your username to >> filter emails in your Gmail box. >> $to = "shreyasbr+phptest@gmail.com <shreyasbr%2Bphptest@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.brown@parasane.net || danbrown@php.net >> http://www.parasane.net/ || >> http://www.pilotpig.net/ >> > > > > -- > Regards, > Shreyas Agasthya > -- Regards, Shreyas Agasthya

« previous php.general (#306604) next »