I am trying to get php to send a new user an activation email when creating an account. My problem is not with the code for this process, but with php sending out emails.
So far I have install Xampp on Ubuntu server 12.04 with a Kubuntu desktop installed. I have also installed pear using the sudo apt-get install php-pear
command.
Finally I installed postfix. When I load my page in the browser I recieve the following errors:
Deprecated: Assigning the return value of new by reference is deprecated in /opt/lampp/lib/php/Mail.php on line 55
Deprecated: Assigning the return value of new by reference is deprecated in /opt/lampp/lib/php/Mail.php on line 135
Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /opt/lampp/lib/php/Mail/smtp.php on line 167
Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /opt/lampp/lib/php/Net/SMTP.php on line 290
Strict Standards: Non-static method PEAR::raiseError() should not be called statically, assuming $this from incompatible context in /opt/lampp/lib/php/Mail/smtp.php on line 168
Thanks for your reply! I am still having some problems though Heres my code:
<?php
include("Mail.php");
$recipients = "[email protected]";
$headers["From"] = "[email protected]";
$headers["To"] = "[email protected]";
$headers["Subject"] = "Test message";
$body = "TEST MESSAGE!!!";
$params["host"] = "smtp.google.com";
$params["port"] = "465";
$params["auth"] = true;
$params["username"] = "[email protected]";
$params["password"] = "gmailpassword(my real password is entered here)";
// Create the mail object using the Mail::factory method
$mail_object =& Mail::factory("smtp", $params);
$mail_object->send($recipients, $headers, $body);
?>
Here's the result of the debug:
object(PEAR_Error)#4 (8) {
["error_message_prefix"]=> string(0) ""
["mode"]=> int(1)
["level"]=> int(1024)
["code"]=> NULL
["message"]=> string(52) "unable to connect to smtp server smtp.google.com:465"
["userinfo"]=> NULL
["backtrace"]=> array(3) { [0]=> array(6) { ["file"]=> string(27) "/opt/lampp/lib/php/PEAR.php" ["line"]=> int(533) ["function"]=> string(10) "PEAR_Error" ["class"]=> string(10) "PEAR_Error" ["type"]=> string(2) "->" ["args"]=> array(5) { [0]=> string(52) "unable to connect to smtp server smtp.google.com:465" [1]=> NULL [2]=> int(1) [3]=> int(1024) [4]=> NULL } } [1]=> array(7) { ["file"]=> string(32) "/opt/lampp/lib/php/Mail/smtp.php" ["line"]=> int(169) ["function"]=> string(10) "raiseError" ["class"]=> string(4) "PEAR" ["object"]=> object(Mail_smtp)#1 (10) { ["host"]=> string(15) "smtp.google.com" ["port"]=> string(3) "465" ["auth"]=> bool(true) ["username"]=> string(25) "[email protected]" ["password"]=> string(28) "Fakepasswordforstackoverflow" ["localhost"]=> string(9) "localhost" ["timeout"]=> NULL ["verp"]=> bool(false) ["debug"]=> bool(false) ["sep"]=> string(2) " " } ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> string(52) "unable to connect to smtp server smtp.google.com:465" } } [2]=> array(7) { ["file"]=> string(32) "/media/HDD2/NJmedia/mailtest.php" ["line"]=> int(23) ["function"]=> string(4) "send" ["class"]=> string(9) "Mail_smtp" ["object"]=> object(Mail_smtp)#1 (10) { ["host"]=> string(15) "smtp.google.com" ["port"]=> string(3) "465" ["auth"]=> bool(true) ["username"]=> string(25) "[email protected]" ["password"]=> string(28) "Fakepasswordforstackoverflow" ["localhost"]=> string(9) "localhost" ["timeout"]=> NULL ["verp"]=> bool(false) ["debug"]=> bool(false) ["sep"]=> string(2) " " } ["type"]=> string(2) "->" ["args"]=> array(3) { [0]=> string(25) "[email protected]" [1]=> array(3) { ["From"]=> string(25) "[email protected]" ["To"]=> string(25) "[email protected]" ["Subject"]=> string(12) "Test message" } [2]=> string(15) "TEST MESSAGE!!!" } } }
["callback"]=> NULL
}
send()
like so:var_dump($mail_object->send($recipients, $headers, $body));
. – Shismtp.gmail.com
for Gmail? – Shi