I am trying to send outgoing emails from my PHP app. Here is the error I get:
“Fatal error: Class ‘PHPMailer’ not found in /usr/share/nginx/templates/webapp.php”
And here is my PHP code for sending the mail, with the require commented out:
//require ( ‘class.phpmailer.php’);
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = “mail.yourdomain.com”; // SMTP server
$mail->SMTPDebug = 0; // enables SMTP debug information (for testing)
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = “tls”; // sets the prefix to the servier
$mail->Host = “smtp.gmail.com”; // sets GMAIL as the SMTP server
$mail->Port = 587; // set the SMTP port for the GMAIL server
<etc…>
$mail -> isHTML(true); // ALLOWS HTML EMAIL FORMATTING
$mail-> Subject = $emailsubject ;
$mail -> Body = $emailbody ;
if ($mail->Send() == false )
{
die($mail->ErrInfo) ;
}
When I include the ‘require’ statement, I get the following error:
Warning: require(class.phpmailer.php): failed to open stream: No such file or directory in /usr/share/nginx/templates/webapp.php
Help? Thanks!!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Ok, when you uncomment the require function it looks for the file class.phpmailer.php so you either need to put that file in the same directory as webapp.php or you need to specify where the php script is. You can modify your require function to point to the script so it would look somethikng like this
require ('path/to/file/class.phpmailer.php');
Hope this helps.
Good Luck!
try with the latest PHPMailer example in here >> https://github.com/PHPMailer/PHPMailer
and you can check whether MTA is working on your machine(linux) by sending a test email by following command
echo "this is email body"|mail -s "This is email subject" youremail@emailhost.com
This comment has been deleted
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.