Page 1 of 1

PHP mailer issue

Posted: Wed Nov 23, 2022 10:24 am
by tba
Have tried to use the contact form wizard to create a contact form. All works well but no emails are sent or received. Have contacted my web host who informs me that the SMTP is not setup or the phpmailer.php either. They also offer the below code as a solution.

So how do I solve this, it shouldn't be rocket science to setup a simple contact form using WYSWYG and as a non-programmer it seems to me that some vital information is not present ...

Grateful for any suggestions
--------------------------------------------------------
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';
$mail = new PHPMailer();

$mail->isSMTP();
$mail->Host = 'mailcluster.loopia.se';
$mail->SMTPAuth = true;
$mail->Username = 'user@example.com'; // SMTP username
$mail->Password = 'secret'; // SMTP password
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->CharSet = 'UTF-8';

$mail->From = 'from@example.com';
$mail->FromName = 'Mailer';
$mail->addAddress('joe@example.net', 'Joe User'); // Add a recipient
$mail->addAddress('ellen@example.com'); // Name is optional
$mail->addReplyTo('info@example.com', 'Information');

$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}

Re: PHP mailer issue

Posted: Wed Nov 23, 2022 11:25 am
by Pablo
There is no need to edit the code!
You can configure SMTP options in the advanced properties of the form.

Please do not open multiple topics about the same issue:
https://www.wysiwygwebbuilder.com/forum ... hp?t=95961

Re: PHP mailer issue

Posted: Wed Nov 23, 2022 12:31 pm
by BaconFries
Have contacted my web host who informs me that the SMTP is not setup or the phpmailer.php either.
As previously your host can provide the correct settings required then once you have these you can configure the SMTP settings in the form properties (Advanced->Mail Engine)

Image

Re: PHP mailer issue

Posted: Wed Nov 23, 2022 1:59 pm
by tba
re mail settings

Yes of course and those settings are exactly as described by my web host which begs the question why they say that the phpmailer.php has not been correctly configured and username/pwd double checked as well

Image

Re: PHP mailer issue

Posted: Wed Nov 23, 2022 3:30 pm
by Pablo
If you have used the correct settings then there is most likely something wrong on the server side.
or the email ended up in spam.

Re: PHP mailer issue

Posted: Wed Nov 23, 2022 3:37 pm
by BaconFries
What version of PHP mailer is the server running? for it to work you will need to have PHP 5.6 or higher. Also what does the error log read.

.

Re: PHP mailer issue

Posted: Wed Nov 23, 2022 4:01 pm
by Craig
The information below is from the Loopia website. You are using port 25 for your outgoing mail server. Loopia's email server information specifically says not to use port 25. Without SSL, it says to use port 587. With SSL, use port 465 or with TLS, use 587.

The code that your host sent you uses TLS and port 587.


Email server
To connect with an email client to our mail server, use the following server information. Note that your username is the full email address and we require authentication / verification for outgoing email.

Without SSL
This information is for connections without SSL or TLS. This is the most common option and it works in most email clients.

POP3
Server: mailcluster.loopia.se
Port: 110

IMAP
Server: mailcluster.loopia.se
Port: 143

SMTP
Server: mailcluster.loopia.se
Port: 587 (not 25)

With SSL
If you want to use SSL you should use this information :

POP3
Server: mailcluster.loopia.se
Port: 995

IMAP
Server: mailcluster.loopia.se
Port: 993

SMTP
Server: mailcluster.loopia.se
Port: 465

With
TLS
If you want to use TLS you should use this information instead:

POP3
Server: mailcluster.loopia.se
Port: 110

IMAP
Server: mailcluster.loopia.se
Port: 143

SMTP
Server: mailcluster.loopia.se
Port: 587

Re: PHP mailer issue

Posted: Wed Nov 23, 2022 5:06 pm
by tba
Thanks, that did the trick