Im getting this error in console when trying to send mail:
There was an uncatched exception<br />
Class 'PHPMailer' not found<br />
in line (29) of (/framework/class.wbmailer.php):<br />
wb 2.12.2. Anyone know what is happening ?
It looks like the PHPmailer has not been loaded.
Please follow these steps in exactly order:
- Check if the file include/PHPMailer/PHPMailerAutoload.php exists
- Modify Line: 31 from spl_autoload_register('PHPMailerAutoload', true, true);
to spl_autoload_register('PHPMailerAutoload', true); - Check if the files class.phpmailer.php and class.smtp.php exists in the same folder.
- Check framework/initialize.php from line: 393
// register PHPMailer autoloader ---------------------------------------------------------
$sTmp = (\dirname(__DIR__)).'/include/PHPMailer/PHPMailerAutoload.php';
if (!\function_exists('PHPMailerAutoload') && \is_readable($sTmp)) {
include $sTmp;
}
If there are any uncertainties at points 1, 2 or 3, then re-upload the directory
include/PHPMailer/.
If all these points are in order, the error should normally be resolved.
I made it work, now mails are sending this is the code I am using:
$send_to_email = 'sendto@thisemail.com';
$subject = preg_replace('/[\r\n]/', '', $subject);
$htmlmessage = preg_replace('/[\r\n]/', "<br />\n", $message);
$plaintext = preg_replace(",<br />,", "\r\n", $message);
$plaintext = preg_replace(",</h.>,", "\r\n", $plaintext);
$plaintext = htmlspecialchars_decode(preg_replace(",</?\w+>,", " ", $plaintext), ENT_NOQUOTES);
// create PHPMailer object and define default settings
$mail = new wbmailer();
//Server settings
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'mail.mydomain.me'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'info@mydomain.me'; // SMTP username
$mail->Password = 'mypass'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
//Recipients
$mail->setFrom('info@mydomain.me', 'Hello from website');
// define recipient(s)
$emails = explode(",", $send_to_email);
foreach ($emails as $recip) {
if (trim($recip) != '')
$mail->AddAddress(trim($recip)); // TO:
}
$mail->addReplyTo('info@mydomain.me', 'Info');
//Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $subject;
$mail->Body = $htmlmessage;
$mail->AltBody = $plaintext;
$mail->send();
The mails are sending but I am recieving this error in error log:
/*code removed*/
I would like to get rid of errors in the log..
Quote220-We do not authorize the use of this system to transport unsolicited,
220 and/or bulk e-mail.
in the most cases: the sender-mail-adress is not from the same server or the smtp-server is not on this server
for example: a lot of servers sends smtp-mails only from the own adress
my domain: www.example.com
my mail: mail@example.com - works
my mail: mail@different-domain.com - works not or with hints in the log
my mail: mail@gmail.com - works not or with hints in the log
other example:
my domain: www.example.com
smtp-server: smtp.example.com - works
smtp-server: cp-uk-2.webhostbox.net - works not or with hints in the log
have you try it with "real" ssl on port 465?
also possible: too many mails in a special time limit - on my german server, only 50 mail per hour allowed
simple solution: a short connection problem to the secure server, but the log say's: connection is okay
other example ( im my - maybe "special" case)
i set my mail to ssl-only, ssl with Port: 465, tls with Port 587 is disabled
but in this case, you have a different output in the log - the script try to send a normal php-mail on port 25, if port 465 & SSL is not avaiable
I must enter
$mail->SMTPDebug = 0;
Instead
$mail->SMTPDebug = 2;
Or it will fill in my error log every time main script is triggered.
$mail->SMTPDebug = 0; == no output
$mail->SMTPDebug = 1; == show only errors on the client
$mail->SMTPDebug = 2; == show only errors on the server
$mail->SMTPDebug = 3; == server errors + initial connection informations
$mail->SMTPDebug = 4; == server errors + initial connection informations + even lower-level information
see https://github.com/PHPMailer/PHPMailer/wiki/SMTP-Debugging
here a solution with a own log-file
https://github.com/PHPMailer/PHPMailer/issues/911