zend mail giving mail in unreadable format when using in magento - magento

Used the following code.
$mail = new Zend_Mail();
$mail->setBodyHtml($message)
->setFrom('abc#gty.com', 'abc')
->addTo($to, 'admin')
->setSubject($subj);
This is the part i wrote.
I am getting proper html in $message. The $ variable used above are from retrieved post value. The mail which I am receiving contains contents like :
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
in the starting part rest all the mail content are fine.Thanks in advance

From myunderstanding,i conclude with this part utf-8 adding in your code
$mail = new Zend_Mail('utf-8');
$mail->setBodyHtml($message)
->setFrom('abc#gty.com', 'abc')
->addTo($to, 'admin')
->setSubject($subj);
Hope this helps you.

Related

Codeigniter to Generate Text View

I need to generate Text view of data but some links are working fine but some are not showing the results as text.
http://www.ipaddresshost.com/downloads/ch.cidr - CH CIDR is not in Text Format
http://www.ipaddresshost.com/downloads/af.cidr - AF CIDR is in Text Format
My Code is as under:
$cidr_result = $this->webmodel_downloads->singlecountrycidr($country_code2);
//$this->load->helper('text');
//$this->load->helper('file');
//echo "# Generated ". date('Y-m-d')."\n";
$this->output->set_content_type('text/plain', 'UTF-8');
$this->output->set_header("Content-Type: text/plain");
echo "# Generated ". date('Y-m-d').PHP_EOL;
if (!empty($cidr_result)){
foreach($cidr_result as $row){
echo $row['value'].PHP_EOL;
//print_r($row['value'].PHP_EOL);
}
}
Please help me, if I am doing some mistake. Thank you
I do not Know the Technical Reason behind this but instead of using CodeIgniter function for text header, I used PHP Header and It's working Fine;
header ("Content-type: text/plain");

special character in message are encoded when it's delivered

I'm using Laravel-4-Nexmo package to send sms but the message is encoded on delivery .
$receiverNumber = "xxxxxxxxxxx"
$message = "hi from nexmo ? ";
$options = array( 'status-report-req' => 1 );
$Nexmo = Nexmo::sendSMS('me', $receiverNumber , $message , $options);
and received message looks like this :
hi+from+nexmo+%3F+
I would like to receive as
hi from nexmo ?
I look forward to see what could be the solution
Probably the mentioned package does not encode the given message so you should use urlencode($yourString) before using the pacckage
I do not know what was wrong with my code above, and I decided to use similar package and it works now. you can find the package here https://github.com/Artistan/nexmo

Subject in PHPmail $head gets doubled and in wrong encoding

Im using IPN to send mail to customers after a purchase. Everythings going well except one small annoying thing. When I test to buy a product with my mail as buyer the mail in my mail inbox looks like this: http://snag.gy/grrMy.jpg <- it has double subject after itself and the first one not changed into UTF-8 - why is this? And if I click on that mail suddenly only the UTF-8 coded subject will show (as intended) like this: http://snag.gy/k5VyF.jpg
Here is the PHP code that I use:
$to = filter_var($ipn_post_data[payer_email], FILTER_SANITIZE_EMAIL);
$date = date('Y-m-d');
$subject = "Tack för Ert köp! / Thank you for your order!";
$headerFields = array(
'Date: ' . date('r', $_SERVER['REQUEST_TIME']),
"Subject: =?UTF-8?Q?".imap_8bit($subject)."?=",
"From: {$to}",
"MIME-Version: 1.0",
"Content-Type: text/html;charset=utf-8"
);
mail($to, $subject, $message, implode("\r\n", $headerFields));
So the only "problem" really is that whn inbox the mails subject gets doubled with the first one with wrong encoding and it looks bad. Anyone that has input on this?
You pass $subject to mail() twice -- once in the second argument, and once in the fourth as part of $headerFields.
Try passing null as the second argument instead.

PHP parse error in rss parse function

I have a client who needs a website urgently, but I have no access to information such as the control panel.
PHP Version is 4.4 Which is a pain as I'm used to 5.
The first problem is I keep getting:
Parse error: parse error, unexpected T_OBJECT_OPERATOR, expecting ')' in D:\hshome\*******\********\includes\functions.php on line 37
This is the function in question:
function read_rss($display=0,$url='') {
$doc = new DOMDocument();
$doc->load($url);
$itemArr = array();
foreach ($doc->getElementsByTagName('item') as $node) {
if ($display == 0) {
break;
}
$itemRSS = array(
'title'=>$node->getElementsByTagName('title')->item(0)->nodeValue,
'description'=>$node->getElementsByTagName('description')->item(0)->nodeValue,
'link'=>$node->getElementsByTagName('link')->item(0)->nodeValue);
array_push($itemArr, $itemRSS);
$display--;
}
return $itemArr;
}
And the line in question:
'title'=>$node->getElementsByTagName('title')->item(0)->nodeValue,
PHP4 does not support object dereferencing. So $obj->something()->something will not work. You need to do $tmp = $obj->something(); $tmp->something...
You can't do that in PHP 4.
Have to do something like
$nodes = $node->getElementsByTagName('title');
$item = $nodes->item(0);
$value = $item->nodeValue,
Try it and it will work.
You can't chain object calls in PHP 4. You're going to have to make each call separately to a variable and store it all.
$titleobj = $node->getElementsByTagName('title');
$itemobj = $titleobj->item(0);
$value = $itemobj->nodeValue;
...
'title'=>$value,
you'll have to do it on all those chained calls
As for .htaccess ... you need to talk to someone who controls the actual server. It sounds like .htaccess isn't allowed to change the setting you're trying to change.
You need to break down that line into individual variables. PHP 4 does not like -> following parentheses. Do this instead:
$title = $node->getElementsByTagName('title');
$title = $title->item(0);
$description = $node->getElementsByTagName('description');
$description = $description->item(0);
$link = $node->getElementsByTagName('link');
$link = $link->item(0);
$itemRSS = array(
'title'=>$title->nodeValue,
'description'=>$description->nodeValue,
'link'=>$link->nodeValue);
The two variable declarations for each may be redundant and condensed, I'm not sure how PHP4 will respond. You can try to condense them if you want.
DOMDocument is php 5 function.You cant use it.
you may need to use DOM XML (PHP 4) Functions

PHP4 including file during session

I am trying to put second language on my webpage. I decided to use different files for different languages told apart by path - language/pl/projects.ln contains Polish text, language/en/projects.ln - English. Those extensions are just to tell language files from other, the content is simple php:
$lang["desc"]["fabrics"]["title"] = "MATERIAŁY";
$lang["desc"]["fabrics"]["short_text"] = "Jakiś tam tekst na temat materiałów";
$lang["desc"]["services"]["title"] = "USŁUGI";
$lang["desc"]["services"]["short_text"] = "Jakiś tam tekst na temat usłóg";
And then on the index page I use it like so:
session_start();
if (isset($_SESSION["lang"])) {
$language = $_SESSION["lang"];
} else {
$language = "pl";
}
include_once("language/$language/projects.ln");
print $lang["desc"]["fabrics"]["title"];
The problem is that if the session variable is not set everything works fine and array item content is displayed but once I change and set $_SESSION["lang"] nothing is displayed. I tested if the include itself works as it should by putting print "sth"; at the beginning of projects.ln file and that works all right both with $_SESSION["lang"] set and unset.
Please help.
Can you test the return value of session_start() - if it's false, it failed to start the session.
Is it being called before you output anything to the browser? If headers were already sent and your error_reporting level is too low, you won't even see the error message.
Stupid, but - do you set value of $_SESSION['lang'] to valid value like "en"? Does the English translation load correctly when you use it as default value in else block instead of "pl"?
"Jakiś tam tekst na temat usłóg" -> "usług" :)
Can you tell us what does this one output:
if(session_start()) {
echo SID, '<br/>';
if(isset($_SESSION['lang'])) {
echo 'lang = "',$_SESSION['lang'], '"';
}
}
Session starts fine and accidentally I managed to fix it.
I renamed $_SESSION['lang'] to $_SESSION['curr_lang'] and it now works allright. It seams like it didn't like the array and session variable having the same name (?).

Resources