setting tags with swiftmailer maligun - swiftmailer

How can i set tags with swiftmailer using mailgun:
$message = \Swift_Message::newInstance()
->setSubject('Hello Email')
->setFrom('send#example.com')
->setTo('recipient#example.com')
->setBody(
$this->renderView(
'HelloBundle:Hello:email.txt.twig',
array('name' => $name)
)
)
;

You should add them in headers :
$message->getHeaders()->addTextHeader('X-Mailgun-Tag', 'tag1');
$message->getHeaders()->addTextHeader('X-Mailgun-Tag', 'tag2');
More info on the doc https://documentation.mailgun.com/en/latest/user_manual.html#sending-via-smtp

Related

Codeigniter 4 DOMPDF (2.0.0) PNG Image loading issue . PHP version 8.0.17

I am having an issue with DOMPDF image loading. I tried all the way to load the image but it won't work on my local / server.
isRemoteEnabled mode changed to true.
I wanted to load a PNG image.
Please help me if you have an idea of how to resolve this issue.
I really appreciate any help you can provide.
When i try this code am getting mem
Constructor:
$options = new Options();
$options->set('defaultFont', 'Helvetica');
$options->set('isRemoteEnabled', TRUE);
$options->set('debugKeepTemp', true);
$options->set('isHtml5ParserEnabled', true);
$this->dompdf = new Dompdf($options);
Fucntion :
$path = '../logo.png';
$type = pathinfo($path, PATHINFO_EXTENSION);
$data = file_get_contents($path);
$base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
#data
$data = array_merge($this->data, [
'title' => $this->title,
'word' => $this->word,
'breadcrumb' => array("0" => array("url" => base_url("home"), "title" => 'Home'), "1" => array("url" => $url,
"title" => $this->word_multi)),
'action' => $url,
'customerID' => $cid,
'siteID' => $site,
'contractRow' => $contractRow,
'base64' => $base64
]);
#Contract file name
$contract = str_replace('/', "-", $contractRow['contractNumber']);
#remove UTF8 issue header
$this->response->removeHeader('Content-Type');
#viewpage data
$this->dompdf->loadHtml(view($this->path_views . 'contract', $data));
$this->dompdf->set_option('defaultMediaType', 'all');
$this->dompdf->setPaper('A4','portrait');
$this->dompdf->render();
$this->dompdf->stream( $contract, array("Attachment" => false));
View
<td width="20%"> <img src="<?php echo $base64; ?>" /></td>

How to get Template Variables inside sendMessage() function in Magento 2?

I am trying to send transactional emails from Magento through Listrack. I have override the default sendMessage function using Magento plugin method. Now I have to fetch template variables and process the data inside this function. I tried a lot and was not able to fetch any details regarding the template. Can anyone please help me to resolve this?
sendMessage function is located in Transport.php file.
Replace the "Email Template Name" with your Template Name
$templateId = Mage::getModel('core/email_template')->loadByCode('Email Template Name')->getId();
$customerEmail = 'your mail Id';
$customerName = 'your name';
$senderName=Mage::getStoreConfig('trans_email/ident_general/name');
$senderEmail= Mage::getStoreConfig('trans_email/ident_general/email');
$sender = Array('name' => $senderName,'email' => $senderEmail);
$vars = array(
'customerName' => $customerName,
'date' => $date,
'url'=>$url,
'number'=>$number,
'barcode'=>$serial_barcode,
);
$translate = Mage::getSingleton('core/translate');
Mage::getModel('core/email_template')->sendTransactional($templateId, $sender, $customerEmail, $customerName, $vars, null);
$translate->setTranslateInline(true);

can't autometic sms using twilio

I can send sms when a user click on a button but i can't send sms when a user set a time or date and sms will send autometic on that times.
in the below code is when a user click on a button for sent sms. Now what thinks should i change to solved my problem.Please help me i need help.
<?php
require __DIR__ . '/vendor/autoload.php';
use Twilio\Rest\Client;
/*echo '+'.$_REQUEST['mobile'];*/
if (isset($_REQUEST['mobile'])) {
$sid = '';
$token = '';
/*$client = new Twilio\Rest\Client($sid,$token);*/
$client = new Client($sid, $token);
$message = $client->messages->create(
'+'.$_REQUEST['mobile'],
array(
'from' => '',
'body' => 'testing'
)
);
}
?>
You Have to add Country code with Plus sign Like +1 for USA and +91 for India.
require __DIR__ . '/vendor/autoload.php';
use Twilio\Rest\Client;
if (isset($_REQUEST['mobile'])) {
$sid = '';
$token = '';
$client = new Client($sid, $token);
$message = $client->messages->create(
'+{Country_Code}'.$_REQUEST['mobile'],
array(
'from' => '',
'body' => 'testing'
)
);
}

CI-Merchant with Sagepay

Has anyone had any luck using SagePay Direct with CI-Merchant? So far the only response I am getting is:
Merchant_response Object
(
[_status:protected] => failed
[_message:protected] =>
[_reference:protected] =>
[_data:protected] =>
[_redirect_url:protected] =>
[_redirect_method:protected] => GET
[_redirect_message:protected] =>
[_redirect_data:protected] =>
)
I haven't used SagePay before and need to get this working urgently. I have added my IP address to the SagePay testing area but am not testing on https as am just on my localhost at the moment.
My code looks like:
public function process_payment()
{
$settings = array (
'vendor' => 'XXX',
'test_mode' => TRUE,
'simulator_mode' => FALSE,
);
$this->merchant->initialize($settings);
//get customer details
$this->load->library('custom_cart');
$customer = $this->custom_cart->get_customer_invoice_info();
$customer_name = '';
if ( ! empty($customer['title'])) $customer_name .= $customer['title'] .' ';
$customer_name .= $customer['forename'];
$customer_name .= $customer['surname'];
$customer_street = $customer['address1'];
$customer_street2 = $customer['address2'];
if ( ! empty($customer['address3'])) $customer_street2 .= $customer['address3'];
//order details
$amt = $this->custom_cart->order_total();
$get_curr = $this->custom_cart->get_currency();
$currencycode = $get_curr['name'];
$shippingamt = $this->custom_cart->shipping_cost();
$itemamt = $this->custom_cart->order_subtotal();
$taxamt = '0';
$invnum = $this->custom_cart->customer_order_no();
$params = array(
'description'=> 'Online order',
'currency'=> $currencycode,
'transaction_id'=> $invnum,
'email'=> $customer['email_address'],
'first_name'=> $customer['forename'],
'last_name'=> $customer['surname'],
'address1'=> $customer_street,
'address2'=> $customer_street2,
'city'=> $customer['town_city'],
'postcode'=> $customer['postcode'],
'country'=> $customer['country'],
'region'=> $customer['county'],
'phone'=> $customer['phone'],
'Amount'=> $amt,
'card_no'=> $this->input->post('creditcard'),
'name'=> $customer_name,
'card_type' => $this->input->post('creditcardtype'),
'exp_month'=> $this->input->post('cardmonth'),
'exp_year' => $this->input->post('cardyear'),
'csc'=> $this->input->post('cardsecurecode')
);
$response = $this->merchant->purchase($params);
echo '<pre>';
print_r($response);
}
(all the values for the params are valid and I have checked the correct values are passed to them. Vendor name is masked here)
Finally tracked down the problem - I was passing through two digits for the year and this is where it was failing (I forgot on my previous merchant I was adding in the 20 prefix)! Thank you for your help. (If anyone has a similar problem I tracked it down by echoing a response from each function in the function trail)

Magento WS-I compliant v2 API WSDL web service SOAP-ERROR: Encoding: object has no 'sessionId' property

I'm using Magento v2 web service in WS-I compliant mode
when try to list product i get exception
SOAP-ERROR: Encoding: object has no 'sessionId' property
my code is listed below
$proxy = new SoapClient('http://127.0.0.1/Magento1620/index.php/api/v2_soap?wsdl', array('trace' => 1, 'connection_timeout' => 120));
$sessionId = $proxy->login(array(
'username' => "zzc000",
'apiKey' => "zzc000"
));
$filters = array(
'sku' => array('like'=>'zol%')
);
$products = $proxy->catalogProductList($sessionId, $filters);
Please help, thanks
In WS-I mode, there are some minor differences in using the API.
The result of $proxy->login() is an object. You need to extract the sessionId.
When calling $proxy->catalogProductList(), you need to provide the parameters in an associative array (just like you did with $proxy->login()).
Please try this:
<?php
try {
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
$proxy = new SoapClient('http://127.0.0.1/Magento1620/index.php/api/v2_soap?wsdl', array('trace' => 1, 'connection_timeout' => 120));
$session = $proxy->login(array(
'username' => "zzc000",
'apiKey' => "zzc000"
));
$sessionId = $session->result;
$filters = array(
'sku' => array('like'=>'zol%')
);
$products = $proxy->catalogProductList(array("sessionId" => $sessionId, "filters" => $filters));
echo '<h1>Result</h1>';
echo '<pre>';
var_dump($products);
echo '</pre>';
} catch (Exception $e) {
echo '<h1>Error</h1>';
echo '<p>' . $e->getMessage() . '</p>';
}
The same applies to other method calls for the WS-I compliant v2 SOAP API.

Resources