yazakib Posted January 27, 2010 Share Posted January 27, 2010 Hi Guys, So I haven't really used PHP for the past I'd say 2 years, so I guess i'm just looking for a fresh start with it. I've been going through tutorials and stuff to get my sea legs back and I ran into a snag because I was trying to create a mailer (just like a simple comment form) but I need to run it through Gmail's smtp server. That means it needs to authorize my username and password. So I looked up some stuff and found this PHPMailer. I've copy/pasted code and added in my username and password and I come up with the same problem this: Strict Standards: date() [function.date]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Pacific/Honolulu' for '-10.0/no DST' instead in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\phpmailer\class.phpmailer.php on line 1925 Strict Standards: date() [function.date]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Pacific/Honolulu' for '-10.0/no DST' instead in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\phpmailer\class.phpmailer.php on line 1929 SMTP Error: Could not connect to SMTP host. Message was not sent Mailer Error: SMTP Error: Could not connect to SMTP host. Anyone know how to fix it? Or does anyone know a simpler way of passing my username and password to Gmail? Quote Link to comment https://forums.phpfreaks.com/topic/189948-phpmailer-wtf/ Share on other sites More sharing options...
PFMaBiSmAd Posted January 27, 2010 Share Posted January 27, 2010 Could not connect to SMTP host. Either the host name or the port that you used is not correct or your ISP or a firewall is blocking the port that you need to use. It would take seeing what you are using to be able to help you. As to the rest of the errors, set the timezone using one of the methods mentioned in the error message. Quote Link to comment https://forums.phpfreaks.com/topic/189948-phpmailer-wtf/#findComment-1002224 Share on other sites More sharing options...
yazakib Posted January 27, 2010 Author Share Posted January 27, 2010 <?php date_default_timezone_set('Pacific/Honolulu'); require("phpmailer/class.phpmailer.php"); $mailer = new PHPMailer(); $mailer->IsSMTP(); $mailer->Host = 'ssl://smtp.gmail.com:465'; $mailer->SMTPAuth = TRUE; $mailer->Username = '[email protected]'; // Change this to your gmail adress $mailer->Password = 'pw'; // Change this to your gmail password $mailer->From = '[email protected]'; // This HAVE TO be your gmail adress $mailer->FromName = 'Brodie'; // This is the from name in the email, you can put anything you like here $mailer->Body = 'Hello World'; $mailer->Subject = 'Hello World'; $mailer->AddAddress('[email protected]'); // This is where you put the email adress of the person you want to mail if(!$mailer->Send()) { echo "Message was not sent<br/ >"; echo "Mailer Error: " . $mailer->ErrorInfo; } else { echo "Message has been sent"; } ?> thanks for helping me get rid of that error. this is what the code is and this is what it outputs: SMTP Error: Could not connect to SMTP host. Message was not sent Mailer Error: SMTP Error: Could not connect to SMTP host. Quote Link to comment https://forums.phpfreaks.com/topic/189948-phpmailer-wtf/#findComment-1002231 Share on other sites More sharing options...
PFMaBiSmAd Posted January 27, 2010 Share Posted January 27, 2010 Should work - $mailer->Host = 'smtp.gmail.com'; $mailer->Port = 465; You will also need the php OpenSSL extension enabled. Quote Link to comment https://forums.phpfreaks.com/topic/189948-phpmailer-wtf/#findComment-1002238 Share on other sites More sharing options...
yazakib Posted January 27, 2010 Author Share Posted January 27, 2010 thanks, just to verify I need to download and install the OpenSSL class first? Or is there a way to just enable it from what i've installed (php6) Quote Link to comment https://forums.phpfreaks.com/topic/189948-phpmailer-wtf/#findComment-1002239 Share on other sites More sharing options...
PFMaBiSmAd Posted January 27, 2010 Share Posted January 27, 2010 If php is installed correctly, all you would need to do is remove the ; to uncomment the following line in the php.ini and stop and start the web server to get the change to take effect - ;extension=php_openssl.dll Confirm that the extension is actually loaded using a phpinfo() statement. Quote Link to comment https://forums.phpfreaks.com/topic/189948-phpmailer-wtf/#findComment-1002240 Share on other sites More sharing options...
yazakib Posted January 27, 2010 Author Share Posted January 27, 2010 Thanks for the help... now it just takes forever to load the page and when it does it doesn't output anything, not even an error, just a blank page. Quote Link to comment https://forums.phpfreaks.com/topic/189948-phpmailer-wtf/#findComment-1002288 Share on other sites More sharing options...
yazakib Posted January 27, 2010 Author Share Posted January 27, 2010 I did as you said I finally got the OpenSSL up and working after a lot of trial and error. OpenSSL support is enabled according to phpinfo(). Yet the page keeps timing out without sending anything. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/189948-phpmailer-wtf/#findComment-1002312 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.