composer php - Fatal error: require(): Failed opening required '../PHPMailerAutoload.php' (include_path='.:/usr/local/php56/pear') -


first time using phpmailer, , can't seem passed require error .. installed composer did require phpmailer/phpmailer , tried changing paths .. still can't pass error message:

fatal error: require(): failed opening required '../phpmailerautoload.php' (include_path='.:/usr/local/php56/pear') in /home/hiinfo53/public_html/grandbluehawaii.com/cgifile/contact_phpmailer.php on line 15

<?php /**  * example shows how handle simple contact form.  */  echo getcwd(); $msg = ''; //don't run unless we're handling form submission if (array_key_exists('email', $_post)) {     date_default_timezone_set('etc/utc');      require '../phpmailerautoload.php';      //create new phpmailer instance      $mail = new phpmailer;     //tell phpmailer use smtp - requires local mail server     //faster , safer using mail()     $mail->issmtp();     $mail->host = 'usm1260.sgded.com';     $mail->port = 465;     $mail->smtpsecure = 'ssl';     //use fixed address in own domain address     //**do not** use submitter's address here forgery     //and cause messages fail spf checks     $mail->setfrom('contact@grandbluehawaii.com', 'first last');     //send message yourself, or whoever should receive contact submissions     $mail->addaddress('gail@hiinfo.com', 'grand blue hawaii');     //put submitter's address in reply-to header     //this fail if address provided invalid,     //in case should ignore whole request     if ($mail->addreplyto($_post['email'], $_post['name'])) {         $mail->subject = 'a user has contacted grandbluehawaii.com';         //keep simple - don't use html         $mail->ishtml(false);         //build simple message body         $mail->body = <<<eot "aloha,\n\n" "a user visiting grandbluehawaii.com has sent message".\n\n" "please make sure reply-to's email directed user's email address".\n\n" email: {$_post['email']} name: {$_post['name']} message: {$_post['message']} eot;         //send message, check errors         if (!$mail->send()) {             //the reason failing send in $mail->errorinfo             //but shouldn't display errors users - process error, log on server.             $msg = 'sorry, went wrong. please try again later.';         } else {             $msg = 'message sent! mahalo contacting grand blue hawaii.';         }     } else {         $msg = 'invalid email address, message ignored.';     } } ?> <!doctype html> <html lang="en"> <head>     <meta charset="utf-8">     <title>contact form</title> </head> <body> <h1>contact us</h1> <?php if (!empty($msg)) {     echo "<h2>$msg</h2>"; } ?> <form method="post">     <label for="name">name: <input type="text" name="name" id="name"></label><br>     <label for="email">email address: <input type="email" name="email" id="email"></label><br>     <label for="message">message: <textarea name="message" id="message" rows="8" cols="20"></textarea></label><br>     <input type="submit" value="send"> </form> </body> </html> 

you have saved lot of pain reading the readme, tells how load phpmailer - has changed phpmailer 6.0. phpmailerautoload.php not exist more. there info upgrading form older versions in the upgrading guide, since new project, should never have got point, suspect got started using obsolete script elsewhere. bad idea.

install phpmailer using composer:

composer require phpmailer/phpmailer 

in script, import class namespace, load composer's autoloader, create phpmailer instance, , autoload right classes automatically:

use phpmailer\phpmailer\phpmailer; require 'vendor/autoload.php'; $mail = new phpmailer(); 

that's there it. if you're using smtp, you'll need use phpmailer\phpmailer\smtp well. when you're using composer, should never have @ in vendor/.

if don't want or cannot run composer on server, run locally, , upload vendor folder along rest of code.

if don't want use composer, can load classes in src/ manually.

all of covered in readme.


Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -