so this is my first time asking here. I have been trying to enable any SMTP for my company's Testlink. However, I cant figure out why I cant manage to make it work since 8 hours ago. been spending my office hours trying to solve this problem and googling there and here but sadly, it seems like none of the solution works for me. if anyone could please kindly revise my code, I would be glad to have your kind help.
the error mostly about:
SMTP -> FROM SERVER:
SMTP -> FROM SERVER:
SMTP -> ERROR: EHLO not accepted from server:
SMTP -> FROM SERVER:
SMTP -> ERROR: HELO not accepted from server:
SMTP -> ERROR: AUTH not accepted from server:
SMTP -> NOTICE: EOF caught while checking if connectedSMTP Error: Could not authenticate. PROBLEMS SENDING MAIL TO: sapurabugzilla#gmail.com
Mailer Error: SMTP Error: Could not authenticate.
and most of the time it showed it cannot load TLS string.
here is my config.inc.php file :
/* [SMTP] */
/**
* #var string SMTP server name or IP address ("localhost" should work in the most cases)
* Configure using custom_config.inc.php
* #uses lib/functions/email_api.php
*/
// SMTP server Configuration ("localhost" is enough in the most cases)
$g_smtp_host = 'smtp.gmail.com:465'; # SMTP server MUST BE configured
# Configure using custom_config.inc.php
$g_tl_admin_email = 'sapuratestlink#gmail.com'; # for problem/error notification
$g_from_email = 'sapuratestlink#gmail.com'; # email sender
$g_return_path_email = 'sapuratestlink#gmail.com';
# Urgent = 1, Not Urgent = 5, Disable = 0
$g_mail_priority = 5;
/**
* Taken from mantis for phpmailer config
* select the method to mail by:
* PHPMAILER_METHOD_MAIL - mail()
* PHPMAILER_METHOD_SENDMAIL - sendmail
* PHPMAILER_METHOD_SMTP - SMTP
*/
$g_phpMailer_method = PHPMAILER_METHOD_SMTP;
/** Configure only if SMTP server requires authentication */
$g_smtp_username = 'sapuratestlink#gmail.com'; # user
$g_smtp_password = 'xxxxxxxx'; # password
/**
* This control the connection mode to SMTP server.
* Can be '', 'ssl','tls'
* #global string $g_smtp_connection_mode
*/
$g_smtp_connection_mode = '';
/**
* The smtp port to use. The typical SMTP ports are 25 and 587. The port to use
* will depend on the SMTP server configuration and hence others may be used.
* #global int $g_smtp_port
*/
$g_smtp_port = 465;
class.phpmailer.php file:
/**
* Sets the Sender email (Return-Path) of the message. If not empty,
* will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
* #var string
*/
public $Sender = 'sapuratestlink#gmail.com';
/**
* Sets the Subject of the message.
* #var string
*/
public $Subject = '';
/**
* Sets the Body of the message. This can be either an HTML or text body.
* If HTML then run IsHTML(true).
* #var string
*/
public $Body = '';
/**
* Sets the text-only body of the message. This automatically sets the
* email to multipart/alternative. This body can be read by mail
* clients that do not have HTML email capability such as mutt. Clients
* that can read HTML will view the normal Body.
* #var string
*/
public $AltBody = '';
/**
* Sets word wrapping on the body of the message to a given number of
* characters.
* #var int
*/
public $WordWrap = 0;
/**
* Method to send mail: ("mail", "sendmail", or "smtp").
* #var string
*/
public $Mailer = 'smtp';
/**
* Sets the path of the sendmail program.
* #var string
*/
public $Sendmail = '/usr/sbin/sendmail';
/**
* Path to PHPMailer plugins. Useful if the SMTP class
* is in a different directory than the PHP include path.
* #var string
*/
public $PluginDir = '';
/**
* Sets the email address that a reading confirmation will be sent.
* #var string
*/
public $ConfirmReadingTo = 'sapuratestlink#gmail.com';
/**
* Sets the hostname to use in Message-Id and Received headers
* and as default HELO string. If empty, the value returned
* by SERVER_NAME is used or 'localhost.localdomain'.
* #var string
*/
public $Hostname = '';
/**
* Sets the message ID to be used in the Message-Id header.
* If empty, a unique id will be generated.
* #var string
*/
public $MessageID = '';
/////////////////////////////////////////////////
// PROPERTIES FOR SMTP
/////////////////////////////////////////////////
/**
* Sets the SMTP hosts. All hosts must be separated by a
* semicolon. You can also specify a different port
* for each host by using this format: [hostname:port]
* (e.g. "smtp1.example.com:25;smtp2.example.com").
* Hosts will be tried in order.
* #var string
*/
public $Host = 'smtp.gmail.com:465';
/**
* Sets the default SMTP server port.
* #var int
*/
public $Port = 465;
/**
* Sets the SMTP HELO of the message (Default is $Hostname).
* #var string
*/
public $Helo = 'Hi from Admin Testlink';
/**
* Sets connection prefix.
* Options are "", "ssl" or "tls"
* #var string
*/
// public $SMTPSecure = 'tls';
/**
* Sets SMTP authentication. Utilizes the Username and Password variables.
* #var bool
*/
public $SMTPAuth = true;
/**
* Sets SMTP username.
* #var string
*/
public $Username = 'sapuratestlink#gmail.com';
/**
* Sets SMTP password.
* #var string
*/
public $Password = 'xxxxx';
/**
* Sets the SMTP server timeout in seconds.
* This function will not work with the win32 version.
* #var int
*/
public $Timeout = 10;
/**
* Sets SMTP class debugging on or off.
* #var bool
*/
public $SMTPDebug = true;
/**
please help me if you're free ! thank you.
change the following line in config.inc.php file
From :
$g_smtp_host = 'smtp.gmail.com:465';
To :
$g_smtp_host = 'smtp.gmail.com';
and try.
i had less stackoverflow reputation to comment your question so only posting it as answer.
Remove port from
$g_smtp_host = 'smtp.gmail.com:465';
like
$g_smtp_host = 'smtp.gmail.com';
and add port below as
$g_smtp_port = 465;
and select connection mode as ssl
$g_smtp_connection_mode = 'ssl';
Related
I have Created a save quote extension for one of my clients every thing is working fine
But when a customer print a pdf Quote its show the POUND symbol instead of showing the quote currency code EURO My code is given below I have tried many ways to add currency code but it is not working
public function __construct(
\Magento\Payment\Helper\Data $paymentData,
\Magento\Framework\Stdlib\StringUtils $string,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Framework\Filesystem $filesystem,
Config $pdfConfig,
\Magento\Sales\Model\Order\Pdf\Total\Factory $pdfTotalFactory,
\Magento\Sales\Model\Order\Pdf\ItemsFactory $pdfItemsFactory,
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
\Magento\Framework\Translate\Inline\StateInterface $inlineTranslation,
\Magento\Sales\Model\Order\Address\Renderer $addressRenderer,
AddressQuoteRenderer $addressQuoteRenderer,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Store\Model\App\Emulation $appEmulation,
\Magento\Framework\Pricing\Helper\Data $helper,
OrderFactory $orderFactory,
array $data = []
) {
$this->orderFactory = $orderFactory;
$this->addressQuoteRenderer = $addressQuoteRenderer;
$this->helper = $helper;
$this->_appEmulation = $appEmulation;
parent::__construct(
$paymentData,
$string,
$scopeConfig,
$filesystem,
$pdfConfig,
$pdfTotalFactory,
$pdfItemsFactory,
$localeDate,
$inlineTranslation,
$addressRenderer,
$storeManager,
$appEmulation,
$data
);
}
/**
* Return PDF document
*
* #param Collection $quotes
*
* #return \Zend_Pdf
* #throws \Magento\Framework\Exception\LocalizedException
* #throws \Zend_Pdf_Exception
*/
public function getPdf($quotes = [])
{
$this->_beforeGetPdf();
$this->_initRenderer('order');
$pdf = new \Zend_Pdf();
$this->_setPdf($pdf);
$order = $this->orderFactory->create();
foreach ($quotes as $quote) {
if ($quote->getStoreId()) {
$this->_appEmulation->startEnvironmentEmulation($quote->getStoreId());
$this->_storeManager->setCurrentStore($quote->getStoreId());
}
$page = $this->newPage();
$this->_setFontBold($page, 10);
$quote->setQuote($quote);
/* Add image */
$this->insertLogo($page, $quote->getStore());
/* Add address */
$this->insertAddress($page, $quote->getStore());
/* Add head */
$this->insertOrder($page, $quote, false);
/* Add table */
$this->_drawHeader($page);
$this->_initRenderer('default');
/* Add body */
$taxTotal = 0;
foreach ($quote->getAllItems() as $item) {
if ($item->getParentItem()) {
continue;
}
/* Keep it compatible with the invoice */
$item->setQty($item->getQty());
$item->setProductType($item->getProduct()->getTypeId());
$this->_initRenderer($item->getProduct()->getTypeId());
$item->setOrderItem($item);
$taxTotal += $item->getTaxAmount();
/* Draw item */
$this->_drawItem($item, $page, $order);
$page = end($pdf->pages);
}
/* Add totals */
$order->setStoreId($quote->getStoreId());
$order->setSubtotal($quote->getSubtotal());
$order->setGrandTotal($quote->getSubtotal() + $taxTotal);
$order->setShippingAmount($quote->getShippingAddress()->getShippingAmount());
$order->setTaxAmount($taxTotal);
$order->setOrder($order);
$this->insertTotals($page, $order);
if ($quote->getStoreId()) {
$this->_appEmulation->stopEnvironmentEmulation();
}
Please Help and suggest to me where I am wrong I am stuck in this problem
Thanks for your help in advance
I am trying to send a modification through Json to my project in Symfony 5, but I only get error responses, as if there is no Url, I have not inserted any API key or any header, I have searched for a guide but I cannot find it:
UserController.php
<?php
namespace App\Controller;
use App\Entity\User;
use App\Repository\UserRepository;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class UserController
{
private $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
/**
* #Route("/user/", name="add_user", methods={"POST"})
* #param Request $request
* #return JsonResponse
*/
public function add(Request $request): JsonResponse
{
$data = json_decode($request->getContent(), true);
$firstName = $data['firstName'];
$lastName = $data['lastName'];
$email = $data['email'];
$phoneNumber = $data['phoneNumber'];
if (empty($firstName) || empty($lastName) || empty($email) || empty($phoneNumber)) {
throw new NotFoundHttpException('Expecting mandatory parameters!');
}
$this->userRepository->saveUser($firstName, $lastName, $email, $phoneNumber);
return new JsonResponse(['status' => 'User created!'], Response::HTTP_CREATED);
}
UserRepository.php:
public function saveUser($firstName, $lastName, $email, $phoneNumber)
{
$newUser = new User();
$newUser
->setFirstName($firstName)
->setLastName($lastName)
->setEmail($email)
->setPhoneNumber($phoneNumber);
$this->manager->persist($newUser);
$this->manager->flush();
}
As for the GET, I have done it correctly and I get an answer with the data.
Your path looks wrong. On the controller action you define the route as:
/**
* #Route("/user/", name="add_user", methods={"POST"})
* #param Request $request
* #return JsonResponse
*/
The add_user is just the internal route name. The url in postman should probably be:
https://127.0.0.1:8000/user/
Additionally, since you did not get any response, so not even a 404 not found, I assume you do not have a web server running right now. If you use the Symfony CLI-tool you can call the command: symfony serve in your project directory to get the web server running. Closing the terminal window or restarting your computer will stop the web server.
Here is my VerifyUserbyEmail custom middle-ware
Can any one please help to sort it out ?
while I have used namespace properly but still getting error
<?php
namespace App\Http\Middleware;
use App\Http\Middleware\Auth;
use Closure;
class VerifyUserbyEmail
{
/**
* Handle an incoming request.
*
* #param \Illuminate\Http\Request $request
* #param \Closure $next
* #return mixed
*/
public function handle($request, Closure $next)
{
$user = \App\User::findOrFail(Auth::id());
if ($user->status == 0){
Auth::logout();
return redirect('login')->with('messege', 'you need to verify your account, check your email');
}
return $next($request);
}
}
Try changing
use App\Http\Middleware\Auth;
with
use Illuminate\Support\Facades\Auth;
I am trying to read the username of a front end user whose uid is known. I tried this in my controller's showAction method:
$objectManger = t3lib_div::makeInstance('Tx_Extbase_Object_ObjectManager');
// get repository
$repository = $objectManger->get('Tx_Extbase_Domain_Repository_FrontendUserRepository ');
$newObject = $repository->findByUid($coupon->getCreator()); //this is the uid of whoever was loggin in
print_r($newObject);
echo $newObject->getUsername(); die;
but when that code runs I get:
Oops, an error occured!
"Tx_Extbase_Domain_Repository_FrontendUserRepository " is not a valid cache entry identifier.
It turns out that $repository is empty, so how do I get fe_user data?
I am using typo3 v4.5 with extbase.
Thanks
Update to show complete answer.
This is the code (it goes in my CouponController) that worked (plus the typoscript mentioned):
/**
* #var Tx_Extbase_Domain_Repository_FrontendUserRepository
*/
protected $userRepository;
/**
* Inject the user repository
* #param Tx_Extbase_Domain_Repository_FrontendUserRepository $userRepository
* #return void */
public function injectFrontendUserRepository(Tx_Extbase_Domain_Repository_FrontendUserRepository $userRepository) {
$this->userRepository = $userRepository;
}
public function showAction(Tx_Coupons_Domain_Model_Coupon $coupon) {
$userRepository = $this->objectManager->get("Tx_Extbase_Domain_Repository_FrontendUserRepository");
$newObject = $userRepository->findByUid($coupon->getCreator());
$this->view->assign('coupon', $coupon);
$this->view->assign('creatorname', $newObject->getUsername() );
}
If you are using extbase yourself you dont have to call makeInstance for your objectManager, it's already there ($this->objectManager).
anyway, you should inject this repository (see my answer here: TYPO3 - Call another repository)
Clear the Cache after the Injection.
You maybe have to disable the recordtype extbase sets for its FrontendUser:
config.tx_extbase.persistence.classes.Tx_Extbase_Domain_Model_FrontendUser.mapping.recordType >
Set the source storage pid where the repository fetches the data from:
/** #var Tx_Extbase_Domain_Repository_FrontendUserRepository $repos */
$repos = $this->objectManager->get("Tx_Extbase_Domain_Repository_FrontendUserRepository");
$querySettings = $repos->createQuery()->getQuerySettings();
$querySettings->setStoragePageIds(array(123, 567));
$repos->setDefaultQuerySettings($querySettings);
$user = $repos->findByUid(56); // Queries for user 56 in storages 123 and 567
I am using this to retrieve the database connection atm.
$db = Zend_Db_Table::getDefaultAdapter();
I do set this up in my config like this:
resources.db.adapter = pdo_mysql
resources.db.isDefaultTableAdapter = true
resources.db.params.host = localhost
resources.db.params.username = root
resources.db.params.password = password
resources.db.params.dbname = db
resources.db.params.profiler.enabled = true
resources.db.params.profiler.class = Zend_Db_Profiler
I would like to output everything to a sql.log for example. Is this possible to apply on the default adapter? for example through the settings, so I can ignore it in production environment?
Much appriciated.
I did look at: How to enable SQL output to log file with Zend_Db? but it didn't seem to cover my issue.
/Marcus
There is an example of extending Zend_Db_Profiler so you can write the queries to /logs/db-queries.log file.
So you have to do the following:
Create My_Db_Profiler_Log class in the library folder
Add the following lines to the application.ini
resources.db.params.profiler.enabled = true
resources.db.params.profiler.class = My_Db_Profiler_Log
Note: be aware, that the log file will become very big, very soon! So it is a good idea to log only the queries you are interested in. And this example should be considered only as a starting point in implementation of such a logging system.
Here is the code for the custom profiler class:
<?php
class My_Db_Profiler_Log extends Zend_Db_Profiler {
/**
* Zend_Log instance
* #var Zend_Log
*/
protected $_log;
/**
* counter of the total elapsed time
* #var double
*/
protected $_totalElapsedTime;
public function __construct($enabled = false) {
parent::__construct($enabled);
$this->_log = new Zend_Log();
$writer = new Zend_Log_Writer_Stream(APPLICATION_PATH . '/logs/db-queries.log');
$this->_log->addWriter($writer);
}
/**
* Intercept the query end and log the profiling data.
*
* #param integer $queryId
* #throws Zend_Db_Profiler_Exception
* #return void
*/
public function queryEnd($queryId) {
$state = parent::queryEnd($queryId);
if (!$this->getEnabled() || $state == self::IGNORED) {
return;
}
// get profile of the current query
$profile = $this->getQueryProfile($queryId);
// update totalElapsedTime counter
$this->_totalElapsedTime += $profile->getElapsedSecs();
// create the message to be logged
$message = "\r\nElapsed Secs: " . round($profile->getElapsedSecs(), 5) . "\r\n";
$message .= "Query: " . $profile->getQuery() . "\r\n";
// log the message as INFO message
$this->_log->info($message);
}
}
?>
Extend the Zend_Db_Profiler to write to an SQL.log and attach the profiler to your db adapter
<?php
class File_Profiler extends Zend_Db_Profiler {
/**
* The filename to save the queries
*
* #var string
*/
protected $_filename;
/**
* The file handle
*
* #var resource
*/
protected $_handle = null;
/**
* Class constructor
*
* #param string $filename
*/
public function __construct( $filename ) {
$this->_filename = $filename;
}
/**
* Change the profiler status. If the profiler is not enabled no
* query will be written to the destination file
*
* #param boolean $enabled
*/
public function setEnabled( $enabled ) {
parent::setEnabled($enabled);
if( $this->getEnabled() ) {
if( !$this->_handle ) {
if( !($this->_handle = #fopen($this->_filename, "a")) ) {
throw new Exception("Unable to open filename {$this->_filename} for query profiling");
}
}
}
else {
if( $this->_handle ) {
#fclose($this->_handle);
}
}
}
/**
* Intercept parent::queryEnd to catch the query and write it to a file
*
* #param int $queryId
*/
public function queryEnd($queryId) {
$state = parent::queryEnd($queryId);
if(!$this->getEnabled() || $state == self::IGNORED) {
return;
}
$profile = $this->getQueryProfile($queryId);
#fwrite($this->_handle, round($profile->getElapsedSecs(),5) . " " . $profile->getQuery() . " " . ($params=$profile->getQueryParams())?$params:null);
}
}
Haven't test it, but it should do the trick. Give it a try and let me know.
Btw you do know that you can log all queries on the mysql as well?
this will let you see sql queries to the web page , IT MIGHT BE OFF TOPIC but it helpful
I am highly recommend you to use ZF debug bar , it will give you very handy information
i am using it to see my doctrine queries , and it had support for zend db too
https://github.com/jokkedk/ZFDebug