Registration email not sending despite C5 mail object working perfectly

Permalink 2 2 Browser Info Environment
Can not get registration verification emails to send and dashboard email test fails despite the mail service working perfectly when tested.

Is at the very least a documentation 'bug' if not a genuine code one. Nobody on the forums knows why this is that I'm able to find, no-one has responded to posts for help so assuming it's a bug.

This below works perfectly and a mail arrives almost instantly but the dashboard test and the verification emails fail.

$mail = \Core::make('mail');
        $mail->setTesting($testing);
        $mail->setBody("Dear concrete5 team\nYour CMS is by far the best I\'ve ever seen.");
        $mail->addParameter('mailContent', $body);
        $mail->load('default', 'packagehandle'); // add any parameters before loading the template
        $mail->setSubject($subject);
        $mail->from($from, $from_name);
        $mail->to($to);
        $mail->sendMail();


Status: New
surefyre
View Best Answer
surefyre replied on at Permalink Reply
surefyre
Even more bizarrely the send-email-to-admin-when-someone-registers email works fine so there's something screwy going on for sure.

Log says:
27 Sep 2017, 09:27:55 Sent Emails testah **EMAILS ARE ENABLED. THIS EMAIL HAS NOT BEEN SENT**
Template Used: validate_user_email
Mail Details: Date: Wed, 27 Sep 2017 09:27:55 +0000
From: [email protected]
Subject: NDA Registration - Validate Email Address
To: [email protected]
Message-ID:
MIME-Version: 1.0
Content-Type: text/plain;
charset="UTF-8"
Content-Transfer-Encoding: 8bit

You must click the following URL in order to activate your account for NDA:

nda.live.thisisthirteen.com/login/callback/concrete/v/88ac869cb3ac

Thanks for your interest in NDA




and an error next to that log entry says:
27 Sep 2017, 09:27:55 Exceptions testah Mail Exception Occurred. Unable to send mail: Unable to send mail: Unknown error
#0 [internal function]: Zend\Mail\Transport\Sendmail->mailHandler('[email protected]', 'NDA R...', 'You must click ...', 'Date: Wed, 27 S...', ' -fconcrete5-no...')
#1 /var/www/nda.live.thisisthirteen.com/concrete/vendor/zendframework/zend-mail/src/Transport/Sendmail.php(138): call_user_func(Array, '[email protected]', 'NDA R...', 'You must click ...', 'Date: Wed, 27 S...', ' -fconcrete5-no...')
#2 /var/www/nda.live.thisisthirteen.com/concrete/src/Mail/Service.php(475): Zend\Mail\Transport\Sendmail->send(Object(Zend\Mail\Message))
#3 /var/www/nda.live.thisisthirteen.com/concrete/src/User/StatusService.php(43): Concrete\Core\Mail\Service->sendMail()
#4 /var/www/nda.live.thisisthirteen.com/concrete/controllers/single_page/register.php(222): Concrete\Core\User\StatusService->sendEmailValidation(Object(Concrete\Core\User\UserInfo))
#5 [internal function]: Concrete\Controller\SinglePage\Register->do_register()
#6 /var/www/nda.live.thisisthirteen.com/concrete/src/Controller/AbstractController.php(172): call_user_func_array(Array, Array)
#7 /var/www/nda.live.thisisthirteen.com/concrete/src/Http/ResponseFactory.php(182): Concrete\Core\Controller\AbstractController->runAction('do_register', Array)
#8 /var/www/nda.live.thisisthirteen.com/concrete/src/Http/ResponseFactory.php(369): Concrete\Core\Http\ResponseFactory->controller(Object(Concrete\Controller\SinglePage\Register))
#9 /var/www/nda.live.thisisthirteen.com/concrete/src/Routing/DispatcherRouteCallback.php(34): Concrete\Core\Http\ResponseFactory->collection(Object(Concrete\Core\Page\Page))
#10 /var/www/nda.live.thisisthirteen.com/concrete/src/Http/DefaultDispatcher.php(122): Concrete\Core\Routing\DispatcherRouteCallback->execute(Object(Concrete\Core\Http\Request))
#11 /var/www/nda.live.thisisthirteen.com/concrete/src/Http/DefaultDispatcher.php(54): Concrete\Core\Http\DefaultDispatcher->handleDispatch(Object(Concrete\Core\Http\Request))
#12 /var/www/nda.live.thisisthirteen.com/concrete/src/Http/Middleware/DispatcherDelegate.php(39): Concrete\Core\Http\DefaultDispatcher->dispatch(Object(Concrete\Core\Http\Request))
#13 /var/www/nda.live.thisisthirteen.com/concrete/src/Http/Middleware/ThumbnailMiddleware.php(60): Concrete\Core\Http\Middleware\DispatcherDelegate->next(Object(Concrete\Core\Http\Request))
#14 /var/www/nda.live.thisisthirteen.com/concrete/src/Http/Middleware/MiddlewareDelegate.php(38): Concrete\Core\Http\Middleware\ThumbnailMiddleware->process(Object(Concrete\Core\Http\Request), Object(Concrete\Core\Http\Middleware\DispatcherDelegate))
#15 /var/www/nda.live.thisisthirteen.com/concrete/src/Http/Middleware/FrameOptionsMiddleware.php(39): Concrete\Core\Http\Middleware\MiddlewareDelegate->next(Object(Concrete\Core\Http\Request))
#16 /var/www/nda.live.thisisthirteen.com/concrete/src/Http/Middleware/MiddlewareDelegate.php(38): Concrete\Core\Http\Middleware\FrameOptionsMiddleware->process(Object(Concrete\Core\Http\Request), Object(Concrete\Core\Http\Middleware\MiddlewareDelegate))
#17 /var/www/nda.live.thisisthirteen.com/concrete/src/Http/Middleware/CookieMiddleware.php(37): Concrete\Core\Http\Middleware\MiddlewareDelegate->next(Object(Concrete\Core\Http\Request))
#18 /var/www/nda.live.thisisthirteen.com/concrete/src/Http/Middleware/MiddlewareDelegate.php(38): Concrete\Core\Http\Middleware\CookieMiddleware->process(Object(Concrete\Core\Http\Request), Object(Concrete\Core\Http\Middleware\MiddlewareDelegate))
#19 /var/www/nda.live.thisisthirteen.com/concrete/src/Http/Middleware/ApplicationMiddleware.php(29): Concrete\Core\Http\Middleware\MiddlewareDelegate->next(Object(Concrete\Core\Http\Request))
#20 /var/www/nda.live.thisisthirteen.com/concrete/src/Http/Middleware/MiddlewareDelegate.php(38): Concrete\Core\Http\Middleware\ApplicationMiddleware->process(Object(Concrete\Core\Http\Request), Object(Concrete\Core\Http\Middleware\MiddlewareDelegate))
#21 /var/www/nda.live.thisisthirteen.com/concrete/src/Http/Middleware/MiddlewareStack.php(86): Concrete\Core\Http\Middleware\MiddlewareDelegate->next(Object(Concrete\Core\Http\Request))
#22 /var/www/nda.live.thisisthirteen.com/concrete/src/Http/DefaultServer.php(85): Concrete\Core\Http\Middleware\MiddlewareStack->process(Object(Concrete\Core\Http\Request))
#23 /var/www/nda.live.thisisthirteen.com/concrete/src/Foundation/Runtime/Run/DefaultRunner.php(115): Concrete\Core\Http\DefaultServer->handleRequest(Object(Concrete\Core\Http\Request))
#24 /var/www/nda.live.thisisthirteen.com/concrete/src/Foundation/Runtime/DefaultRuntime.php(102): Concrete\Core\Foundation\Runtime\Run\DefaultRunner->run()
#25 /var/www/nda.live.thisisthirteen.com/concrete/dispatcher.php(39): Concrete\Core\Foundation\Runtime\DefaultRuntime->run()
#26 /var/www/nda.live.thisisthirteen.com/index.php(3): require('/var/www/nda.li...')
#27 {main}
Template Used: validate_user_email
To: [email protected]
From: [email protected]
Reply-To:
Subject: NDA Registration - Validate Email Address
Body:

You must click the following URL in order to activate your account for NDA:

nda.live.thisisthirteen.com/login/callback/concrete/v/88ac869cb3ac

Thanks for your interest in NDA
surefyre replied on at Best Answer Permalink Reply
surefyre
I believe I found the root of the issue

In my installation, for whatever reason - and this is both dev and live which were both setup as standard C5 installs from 8.2.1 individually - the validation email from and fromname are null and this causes the validation registration email to screw up.

I put this in my package controller to explicitly set the values in C5
//
        // Fix validation email address info cos C5 team forgot to put it in?
        \Config::save('concrete.email.validate_registration.address', '[email protected]');
        \Config::save('concrete.email.validate_registration.name', 'The One Group');


Now it works. I really hope this helps folks with the same issue. Will add it to my bug report.

Now just don't tell the client I spent about a day in total finding this fix...

concrete5 Environment Information

# concrete5 Version
Core Version - 8.2.1
Version Installed - 8.2.1
Database Version - 20170802000000

# concrete5 Packages
The One Group (0.9.53)

# concrete5 Overrides
None

# concrete5 Cache Settings
Block Cache - Off
Overrides Cache - Off
Full Page Caching - Off
Full Page Cache Lifetime - Every 6 hours (default setting).

# Server Software
Apache/2.4.18 (Ubuntu)

# Server API
apache2handler

# PHP Version
7.0.22-0ubuntu0.16.04.1

# PHP Extensions
apache2handler, calendar, Core, ctype, date, dom, exif, fileinfo, filter, ftp, gd, gettext, hash, iconv, json, libsodium, libxml, mbstring, mysqli, mysqlnd, openssl, pcre, PDO, pdo_dblib, pdo_mysql, Phar, posix, readline, Reflection, session, shmop, SimpleXML, sockets, SPL, standard, sysvmsg, sysvsem, sysvshm, tokenizer, wddx, xml, xmlreader, xmlwriter, xsl, Zend OPcache, zip, zlib

# PHP Settings
max_execution_time - 30
log_errors_max_len - 1024
max_file_uploads - 20
max_input_nesting_level - 64
max_input_time - 60
max_input_vars - 1000
memory_limit - 128M
post_max_size - 8M
sql.safe_mode - Off
upload_max_filesize - 2M
mysqli.max_links - Unlimited
mysqli.max_persistent - Unlimited
pcre.backtrack_limit - 1000000
pcre.recursion_limit - 100000
session.cache_limiter - <i>no value</i>
session.gc_maxlifetime - 7200
opcache.max_accelerated_files - 2000
opcache.max_file_size - 0
opcache.max_wasted_percentage - 5

Browser User-Agent String

Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.90 Safari/537.36