Subject in PHPmail $head gets doubled and in wrong encoding - utf-8

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.

Related

Magento 2 sucess/faliure message displaying + concatenated string.

Hello I am new to Magento (Magento 2.1) My problem is that when any message like sign up successfully or order successfully it is displayed word joining with + sign instead of space. like :
please help.
Provide the code where you concatenate the message. The message should be
$this->messageManager->addError( __('This is your error message.') );
//or
$this->messageManager->addError( __('Invalid %s or %s', 'login', 'password') );
//or replace with variables

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

On line email form hangs on php mail() function. What server issue could be causing this?

I have a contact form on my website that has a dead simple php mail() function. I am 99% certain the php is not the issue as I have the exact same function on other sites that works fine.
However, when I try to use the form on one site in particular it seems to hang and not send the email and not redirect to the success page. Would anyone know what could be causing this on the server side?
If anyones interested my php is:
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$company = $_REQUEST['company'] ;
$phone = $_REQUEST['phone'] ;
$message= $_REQUEST['message'] ;
$webmaster_email = "myemail#mysite.com";
$thankyou_page = "http://www.mysite.com/thanks-for-your-inquiry.html";
mail( "$webmaster_email", "Site Form", "From: noreply#mysite.com",
"From: $email \n
Name: $name \n
Phone: $phone\n
Message: $message\n ");
header( "Location: $thankyou_page" );

How to remove U and Y characters for text messages to self?

If I send a text message to my phone via php mail() function, I see a character U after the Subject and Y after the body copy of the email sent. How do I get rid of these letters from the text message?
So, the text message is coming to me like this: Subj:TestingUHello WorldY
I send it with the Subject: Testing and the body: Hello World
Updated with code here:
$headers = 'From: testing#yahoo.com' . "\r\n" . 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail('myphonenumber#sms.mycricket.com', 'Testing', 'Hello World', $headers);
Above is the code I am using, and it is producing the undesired results as described above. How do I get rid of Y and U characters?

zend mail giving mail in unreadable format when using in 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.

Resources