WebsiteBaker Community Forum

WebsiteBaker Support (2.12.x) => General Help & Support => Topic started by: crnogorac081 on July 14, 2019, 10:38:01 PM

Title: wbmailer problem
Post by: crnogorac081 on July 14, 2019, 10:38:01 PM
Im getting this error in console when trying to send mail:

Code: [Select]
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 ?
Title: Re: wbmailer problem
Post by: DarkViper on July 15, 2019, 12:44:45 AM
It looks like the PHPmailer has not been loaded.
Please follow these steps in exactly order:
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.

Title: Re: wbmailer problem
Post by: crnogorac081 on July 15, 2019, 07:25:35 PM
I made it work, now mails are sending this is the code I am using:


Code: [Select]

$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..
Title: Re: wbmailer problem
Post by: Gast on July 16, 2019, 12:24:22 PM
Quote
220-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

Title: Re: wbmailer problem
Post by: crnogorac081 on July 24, 2019, 06:26:10 PM
I must enter
$mail->SMTPDebug = 0;
Instead

$mail->SMTPDebug = 2;

Or it will fill in my error log every time main script is triggered.
Title: Re: wbmailer problem
Post by: Gast on July 25, 2019, 02:33:57 AM
$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