malformed email subject header when subject > 75 chars using codeigniter email lib - email

I'm getting some garble in my MIME headers when the subject is over 75 chars.
When the line break is encoded in the header there is an extra line break that is invalid.
Some email gateways are bouncing the email with a "Malformed MIME field: ?= =?utf-8?Q?SUBJECT?=" error.
Does anyone have any experience with utf-8 problems sending emails with CodeIgniter?
-snip-
Return-Path: ***
Subject: =?utf-8?Q?SUBJECT_LINE <--
?= <-- Problem in Subject header
=?utf-8?Q?SUBECT_LINE_2?= <--
To: ***
Reply-To: ***
-snip-
Update:
This has nothing to do with gmail smtp. I have rewritten the question in the hope that it will help someone out in the future.

Apparently this is a known issue, caused by Subject lines > 75 chars.
http://codeigniter.com/forums/viewthread/154493/P15/#925385
The fix was to change the email config like this:
$config['newline'] = "\r\n";
$config['crlf'] = "\n";

Since I myself had this exact problem I will share the solution here since the one shared does not work with version 2.2
Find this piece of code located in system/libraries/Email.php:365
public function subject($subject)
{
$subject = $this->_prep_q_encoding($subject);
$this->_set_header('Subject', $subject);
return $this;
}
With this one
public function subject($subject)
{
$subject = '=?UTF-8?B?'.base64_encode($subject).'?=';
$this->_set_header('Subject', $subject);
return $this;
}

Related

How to permit arabic characters in url

My url has arabic characters like http://localhost/Mypro/ar/flights/رخيص-هواء-تذاكر-البحرين-إلى-مومباي-بوم-باه and i was route this to a method. When I load this url I've got an error:
Object not found!
The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.
If you think this is a server error, please contact the webmaster.
Error 404
localhost
Apache/2.4.39 (Win64) OpenSSL/1.1.1b PHP/7.2.18.
Can any one help me to fix this issue.
config\route.php
$path = urlencode('الرخيصة من الجو تذاكر - (: وجدت) -to - (: أي) - (: أي) - (: وجدت)');
$route['^(en|ar)/'.$path] = "Seo/viewCities";
config\config.php
$config['permitted_uri_chars'] .= '%D8%A2%D8%A7%D8%A8%D9%BE%D8%AA%D8%AB%D8%AC%DA%86%D8%AD%D8%AE%D8%AF%D8%B0%D8%B1%D8%B2%D8%B3%D8%B4%D8%B5%D8%B6%D8%B7%D8%B8%D8%B9%D8%BA%D9%81%D9%82%DA%A9%DA%AF%D9%84%D9%85%D9%86%D9%88%D9%87%DB%8C%D9%8A%DB%B1%DB%B2%DB%B3%DB%B4%DB%B5%DB%B6%DB%B7%DB%B8%DB%B9%DB%B0';
system\core\uri.php
public function filter_uri(&$str)
{
if (!preg_match("|^[".str_replace(array('\\-', '\-'), '-', preg_quote($this->config->item('permitted_uri_chars'), '-'))."]+$|i", $str))
{
show_error('The URI you submitted has disallowed characters.', 400);
}
}
This piece of code maybe can help
$string ="العربی (العربی";
$string=str_replace(")","",$string);
//and u can use other str_replace
$this->load->helper('text');
$til = url_title(convert_accented_characters($string), 'dash', true);
//$til your slug for url
this work for me :)

Mantis Bug Tracker SOAP API Response XML Error

I am using Mantis Bug Tracker SOAP API, but unfortunately every time it returns to me message like
"looks like we got no XML document",
after tracing the last response I got following message
"<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body><SOAP-ENV:Fault><faultcode xsi:type="xsd:string">Client</faultcode><faultactor xsi:type="xsd:string"></faultactor><faultstring xsi:type="xsd:string">Issue does not exist.</faultstring><detail xsi:type="xsd:string"></detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>"
I hope that, I am getting xml respose back, it appears that there is a addition of "" characters in the beginning.
Any clue or help would be great, in removing those characters.
The code for connecting to MANTIS SOAP API SERVER
<?php
$c = new \SoapClient("http://dev06/api/soap/mantisconnect.php?wsdl", array('trace'=> true, 'encoding'=>' UTF-8', 'soap_version'=>1.2));
$username = "xxxxx";
$password = "xxxxx";
try {
$c->mc_issue_get(trim($username), trim($password), 2331);
} catch (SoapFault $exception) {
var_dump($c->__getLastResponse());
}
?>
I don't see any issue with your code and it works perfectly in my environment with slight modifications:
$c = new \SoapClient("http://localhost/demo/mantisbt-1.2.15/api/soap/mantisconnect.php?wsdl", array('trace'=> true, 'encoding'=>' UTF-8', 'soap_version'=>SOAP_1_2));
$username = "XXXXXXXX";
$password = "XXXX";
try {
$issue = $c->mc_issue_get(trim($username), trim($password), 31);
var_dump($issue);
} catch (SoapFault $exception) {
var_dump($c->__getLastResponse());
}
It could be the soap_version, so may be you could try with soap_version=SOAP_1_1
Oh...!
Finally got the solution for it. Its very simple.
Firstly mantis SOAP API code base contains may be more than 20,000 lines of code. I think there is some where some one is printing some BOM characters.
So best solution would be, just use following function,
ob_clean();
This function must be used in
/library/nusoap/nusoap.php
Because this file has
send_response()
That printouts payload, So just use ob_clean() at the beginning of the send_response() function.
Thanks and hope it will help others.

How to force text/html mime type using PeopleSoft SendMail()

I am trying to send an html formatted email using SendMail() in PeopleCode. What I am trying to do is very a basic html email (e.g. bolded text, a href tags, etc).
We recently upgraded to PeopleTools 8.52
When I use the default SendMail() example from PeopleBooks, The email is sent as plain text, regardless of the fact that I specified the content type as "text/html".
Local string &MAIL_CC, &MAIL_TO, &MAIL_BCC, &MAIL_SUBJECT, &MAIL_TITLES, &MAIL_TEXT, &MAIL_FILES, &MAIL_FROM, &REPLYTO, &SENDER;
Local number &MAIL_FLAGS;
&MAIL_FLAGS = 0;
&MAIL_TO = "laurie_thomas#peoplesoft.com";
&MAIL_CC = "";
&MAIL_BCC = "";
&MAIL_SUBJECT = "Testing SendMail - Are you receiving Attachment?";
&MAIL_TEXT = "This is a test for SendMail function";
&MAIL_FILES = "/data9/ps/e841g2bp/lat/attach.txt";
&MAIL_TITLES = "";
&MAIL_FROM = "peoplesoft#peoplesoft.com";
&MAIL_SEP = ";";
&CONTTYPE = "Content-type: text/html; charset=utf8";
&REPLYTO = "lthomas#peoplesoft.com";
&SENDER = "00972#peoplesoft.com";
&RET = SendMail(&MAIL_FLAGS, &MAIL_TO, &MAIL_CC, &MAIL_BCC, &MAIL_SUBJECT, &MAIL_TEXT, &MAIL_FILES, &MAIL_TITLES, &MAIL_FROM, &MAIL_SEP, &CONTTYPE, &REPLYTO,&SENDER);
If &RET <> 0 Then
MessageBox(0, "", 0, 0, "Return code from SendMail=" | &RET);
End-If;
As it turns out, this is a documented bug observed by Oracle (Bug:13714374). This occurs when upgrading from PeopleTools 8.51 to 8.52 (which is why it happened to us).
Solution from Oracle:
This Bug Fixed in the PT 8.52.08 patch, which became available on
05/24/2012

Zend_Mail will not send bcc to sender address

I have a problem, when I want to send mail to a customer and also to the admins.
The problem is, that the customer receives the mail, but the bcc will not if the from = bcc. Is there any setting I have missed?
Could this be a server issue, or a Zend related one?
Example code I use:
$mail = new Zend_Mail();
$mail->setFrom( 'admin#example.com', 'Admin' )
->addTo( 'customer#anydomain.com', 'Customer' )
->setBodyText( 'Example' )
->addBcc('admin#example.com');
$mail->send();
The headers are (from $mail->getHeaders()):
array(3) {
["From"]=>
array(2) {
[0]=>
string(26) "Admin <admin#example.com>"
["append"]=>
bool(true)
}
["To"]=>
array(2) {
[0]=>
string(25) "Customer <customer#anydomain.com>"
["append"]=>
bool(true)
}
["Bcc"]=>
array(2) {
[0]=>
string(18) "admin#example.com"
["append"]=>
bool(true)
}
}
I stumbled on this post while working on using Zend_Mail to send a bcc to the sender address and found that for me the following does in fact work:
$fromName = 'admin';
$fromMail = 'sender#mail.com';
$mail = new Zend_Mail();
$mail->setFrom($fromEmail, $fromName);
$mail->addBcc($fromMail);
Even though the bug report http://framework.zend.com/issues/browse/ZF-8723 as linked in RakeshS's post is still marked as unresolved. My Zend version is:
const VERSION = '1.11.12';
It would be interesting to learn whether the problem would also be solved for the original posters for the updated Zend framework, if they may happen to read this
I'm getting the same behavior as you. The sender is not getting the message if the address is added as Bcc. So, it's likely to be a Zend Mail related issue (I don't think we have the same server configuration).
There is a bug added to ZF which almost similar to this issue: http://framework.zend.com/issues/browse/ZF-8723
BTW, you could also get BCC to work with the help of Zend Mail Add Header method. Please try the following work-around:
$mail->addHeader('Bcc', 'admin#example.com');
if you use only Bcc recipients without TO
read this
http://framework.zend.com/issues/browse/ZF-3509

Email sent using contact form displays admins "from" address, and not the visitors email

This page uses Drupals contact form to send emails: http://www.westlake.school.nz/contact
Problem is, the school staff use outlook. When they recieve email from parents etc, the email comes in as
"From: admin#example.com On Behalf Of
Westlake Boys High School"
In Gmail it comes in correctly such as
from Westlake Boys High School
parentsEmailAddress#yahoo.com
Unfortunately, I cannot tell the entire school staff to stop using Outlook and exchange.
Can Drupals drupal_mail function be altered in order to fix this?
From contact.pages.inc:
drupal_mail('contact', 'page_mail', $contact['recipients'], language_default(), $values, $from);
tmsimont explains on this URL (http://api.drupal.org/api/function/drupal_mail#comment-3243) that
the $from parameter will only alter the
From header, not the Sender, Errors-to
or Return-Path.
of the drupal_mail function that is used by contact_mail_page_submit.
with more details (code from the drupal_mail() function)
line 3 - $default_from = variable_get('site_mail', ini_get('sendmail_from'));
line 9 - 'from' => isset($from) ? $from : $default_from,
line 23 - if ($default_from) {
line 24 - // To prevent e-mail from looking like spam, the addresses in the Sender and
line 25 - // Return-Path headers should have a domain authorized to use the originating
line 26 - // SMTP server. Errors-To is redundant, but shouldn't hurt.
line 27 - $headers['From'] = $headers['Sender'] = $headers['Return-Path'] = $headers['Errors-To'] = $default_from;
line 28 - }
line 29 - if ($from) {
line 30 - $headers['From'] = $from;
line 31 - }
line 32 - $message['headers'] = $headers;
So to solve your problem you could implement hook_mail function (http://drupal.org/node/358855#comment-2079266)
More resources can be found here:
1 - http://drupal.org/node/656472
2 - http://drupal.org/node/861562
3 - http://www.nmglc.co.uk/content/overriding-drupals-mail-function