PHP: POIRE aide mail
J'essaie à la poste un paquet pear. Il réussit à envoyer un e-mail mais me donne l'erreur suivante:
Strict Standards: Non-static method Mail::factory() should not be called statically, assuming $this from incompatible context in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\ClientPortal\classes\SupportTickets.php on line 356
Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Mail\smtp.php on line 365
Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 386
Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 391
Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 398
Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 441
Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 230
Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 445
Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Mail\smtp.php on line 376
Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 526
Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 230
Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 529
Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 532
Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 441
Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 230
Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 445
Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 550
Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 694
Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 230
Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 698
Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 706
Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 230
Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 1017
Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 415
Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 230
Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\ClientPortal\classes\SupportTickets.php on line 364
Message successfully sent!
Voici mon code:
function submitTicket(){
$from = "Billy Jones <[email protected]>";
$to = "helpdesk <[email protected]>";
$subject = "Email Test!";
$body = "email test body";
$host = "***";
$username = "***";
$password = "**********";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
}
Peut quelqu'un m'aider ici?
- Pas sûr que je l'ai installé normalement des packages PEAR manuellement, mais le Net_SMTP paquet au moins peuvent être trouvés ici pour l'installation manuelle: pear.php.net/package/Net_SMTP
- merci ça a fonctionné! mais maintenant, je vais avoir des erreurs différentes bien que le courriel a été envoyé avec succès! J'ai mis à jour ma question
- Est l'e-mail envoyé? Il ressemble à la signature de la méthode de PEAR::isError manque l'attribut static, ce qui signifie qu'il va déclencher une erreur E_STRICT en cas d'accès statique via PEAR::isError (). Vous pourriez mettre à jour votre niveau error_reporting (soit en php.ini ou dans votre script php à l'aide de la fonction ini_set) à E_ALL ^ E_STRICT et voir si cela fonctionne.
- a fait le tour!
- Héhé, super, je shouldve écrit une réponse à cela dans le but de recevoir les points de rep. 😉 Content que ça fonctionne bien. 🙂
- s'il vous plaît fermer la question.
- Cela m'a aidé, merci de ne pas fermer la question comme je suis sûr que ça va aider les futurs googlers avec cette erreur, Max doit juste faire son commentaire une réponse,
Vous devez vous connecter pour publier un commentaire.
J'ai posé la même question ici, et de trouver une véritable solution (plutôt que de masquer les erreurs). Lire la réponse à la question ci-dessous pour plus de détails, mais, fondamentalement, il suffit de suivre les trois modifications ci-dessous.
Comment ne pas appeler une fonction statique en php?
Trouver
php/pear/Mail.php
, aller à la ligne 74 et le changement:à
Également dans
php/pear/Mail.php
aller à la ligne 253 et le changement:à
Trouver
php/pear/PEAR.php
, aller à la ligne 250 et changement:à
Merci pour Amal pour montrer comment résoudre ce problème!
/usr/share/php
- à moins que, là où il était pour moi/usr/share/pear/
. Utilisationfind /usr -name pear
pour d'autres systèmes.La stricte erreurs n'empêchent pas le code de travail.
Il suffit de régler le paramètre rapport d'erreurs de
E_ALL & ~E_STRICT
et ils disparaissent comme par magie.Look: j'ai utilisé le
@
signe avant certaines des variables et des méthodes. Et avec cette façon, vous pouvez envoyer un e-mail à l'aide de php5. C'est une vieille approche, mais devrait fonctionner. Bien que vous pourriez être posées à propos de l'activation de ssl dans la configuration, mais c'est un morceau de gâteau. Profitez de. Et, bien sûr alernate mais plus récente et de grande qualité technique, est à l'aide de SwiftMailer .set_error_handler(function...
si vous l'avez, le restaurer commerestore_error_handler();
et ensuite appeler le générateur de troubles des fonctionsDepuis PHP 5, l'appel d'un non-statique méthode d'une autre classe de l'intérieur de la non-statique méthode de un autre classe ist verboten sous
E_STRICT
. Lorsque lePEAR_Mail
package a été créé, c'était un peu obscur de la méta-programmation hack en PHP. AinsiPEAR_Mail
est connu pour cela.La méthode
PEAR::isError()
probablement devrait ont été d'une méthode statique, mais il n'est pas et suppose une instance de contexte avec beaucoup de$this
jeté autour.PEAR_Mail
appelle de manière statique à l'intérieur de sa propre instance de contexte, de sorte que PHP en déduit la valeur de$this
... Qui est toutes sortes de Mauvaises Nouvelles.PEAR_Mail::factory()
devrait être définie commestatic
mais n'est-ce pas, pour des raisons connues seulement par les auteurs originaux. Il TOUJOURS générer que "non méthode statique" message d'avertissement jusqu'à ce que le code est corrigé.Remarque:
PEAR_Mail
n'a pas été touché depuis 2010. S'il vous plaît ne pas l'utiliser...! Pour des solutions de rechange, utiliser Google, Luke!