Jump to content

Recommended Posts

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?

 

Link to comment
https://forums.phpfreaks.com/topic/189948-phpmailer-wtf/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/189948-phpmailer-wtf/#findComment-1002224
Share on other sites

<?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.

Link to comment
https://forums.phpfreaks.com/topic/189948-phpmailer-wtf/#findComment-1002231
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/189948-phpmailer-wtf/#findComment-1002240
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.