For issues related to the current stable release please use it's own Help forum.
IMPORTANT:Please read this before using an git or nightly build version: wiki.webtrees.net/en/GIT

Before asking for help please read "How to request help" by clicking on that tab above here.

TOPIC: Testing send mail with SMTP

Testing send mail with SMTP 6 days 21 hours ago #1

  • hlein
  • hlein's Avatar
  • Offline
  • Junior
  • Posts: 129
Hi,

as it seems that that I cannot make webtrees send emails by SMTP, I want to find out the reason. Althoguh I do not know PHP, I found a script in the Internet and adapted it for my test.
<?php

require './vendor/swiftmailer/swiftmailer/lib/swift_required.php';
/*
use Swift_Mailer;
use Swift_MailTransport;
use Swift_Message;
use Swift_NullTransport;
use Swift_Preferences;
use Swift_SendmailTransport;
use Swift_SmtpTransport;
use Swift_Transport;
*/


$pEmailGmail = '***@gmail.com';
$pPasswordGmail = '***;
$pFromName = 'MundialSYS.com'; //display name

$pTo = 'hlein@gmx.at'; //destination email
$pSubjetc = "Hello MundialSYS"; //the subjetc 
$pBody = '<html><body><p>Hello MundialSYS</p></html></body>'; //body html

$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')
            ->setUsername($pEmailGmail)
            ->setPassword($pPasswordGmail);

$mMailer = Swift_Mailer::newInstance($transport);

$mEmail = Swift_Message::newInstance();
$mEmail->setSubject($pSubjetc);
$mEmail->setTo($pTo);
$mEmail->setFrom(array($pEmailGmail => $pFromName));
$mEmail->setBody($pBody, 'text/html'); //body html

if($mMailer->send($mEmail) == 1){
    echo 'send ok';
}
else {
    echo 'send error';
}
?>

When I try to run, I get this error message:
hl@ubuntu-VirtualBox:/var/www/html/webtrees$ php -f testsmtpmail.php 
PHP Fatal error:  Uncaught Error: Call to undefined method Swift_SmtpTransport::newInstance() in /var/www/html/webtrees/testsmtpmail.php:24
Stack trace:
#0 {main}
  thrown in /var/www/html/webtrees/testsmtpmail.php on line 24

What am I missing?

Thanks in advance
Regards
Helmut
The administrator has disabled public write access.

Testing send mail with SMTP 6 days 18 hours ago #2

  • hlein
  • hlein's Avatar
  • Offline
  • Junior
  • Posts: 129
I could make it work
Regards
Helmut
The administrator has disabled public write access.
Powered by Kunena Forum