I am using PHPmailer version 5.2.22 and losing some part of string from FromName.
For e.g.
Mail sent with FromName : "CONC, abcø"
Outputs FromName : "abcø"
String part "CONC," is removed from FromName of mail received.
Code sample :
<?php
$email = 'waleedAhmed#mymail.com';
$name = 'waleed';
$event_info[0]['organizer_name'] = 'CONC, abcø';
$subject = 'Testing..';
$content = ' content : '. $event_info[0]['organizer_name'];
$objName = new \PHPMailer();
$objName->CharSet = 'UTF-8';
$objName->Mailer = "smtp";
$objName->Host = "mail.mymail.com";
$objName->Port = 25;
$objName->Mailer = "sendmail";
$objName->From = 'donotreply#mymail.com';
$objName->Sender = 'donotreply#mymail.com';
$objName->FromName = $event_info[0]['organizer_name']
$objName->IsHTML(true);
$objName->Body = $content;
$objName->Send();
unset($objName);
// ' \"CONC, abcø\" < donotreply#mymail.com > ';
$objName->FromName = '\"'.$event_info[0]['organizer_name'].'\" < donotreply#mymail.com >';
Working fine.
Related
When request for Transaction using Slimcd. I have issue "Syntax error, malformed JSON ". I have searched through google nothing found useful.
// Create a ProcessTransaction Request class
$request = new Transact_ProcessTransactionRequest() ;
$request->username = '1032';
$request->password = '289075';
$request->clientid = '1032';
$request->siteid = 228226448 ;
$request->priceid = 74 ;
$request->transtype = 'LOAD';
$request->amount = '0.00';
$request->cardnumber = '4111111111111111';
$request->expmonth = '12';
$request->expyear = '49';
$request->product = 'MyPHP';
$request->ver = '1.0';
$request->key = 'SVD-072-5QQ6-5K58';
$reply = $SlimCD->Transact_ProcessTransaction($request);
print_r(json_encode($reply)) ;
Response:
{"response":"Error","responsecode":"2","description":" - Syntax error, malformed JSON","responseurl":"https:\/\/trans.slimcd.com\/soft\/json\/jsonpayment.asp","datablock":""}
i have the following function:
public function getMails()
{
$mails = array();
$numMessages = imap_num_msg($this->imap);
for ($i = 1; $i <= $numMessages; $i++)
{
$header = imap_header($this->imap, $i);
$fromInfo = $header->from[0];
$replyInfo = $header->reply_to[0];
$details = array(
"fromAddr" => (isset($fromInfo->mailbox) && isset($fromInfo->host))
? $fromInfo->mailbox . "#" . $fromInfo->host : "",
"fromName" => (isset($fromInfo->personal))
? $fromInfo->personal : "",
"replyAddr" => (isset($replyInfo->mailbox) && isset($replyInfo->host))
? $replyInfo->mailbox . "#" . $replyInfo->host : "",
"replyName" => (isset($replyInfo->personal))
? $replyInfo->personal : "",
"subject" => (isset($header->subject))
? $header->subject : "",
"udate" => (isset($header->udate))
? $header->udate : ""
);
$bodyText = imap_fetchbody($this->imap,$i,1.2);
if(!strlen($bodyText)>0){
$bodyText = imap_fetchbody($this->imap,$i,1);
}
$details['body'] = $bodyText;
$uid = imap_uid($this->imap, $i);
$current_mail = array('header'=>$header, 'from'=>$fromInfo, 'reply'=>$replyInfo, 'details'=>$details);
$mails[$i] = $current_mail;
}
}
However there is a problem with the body text.
This is a test mail that i sendt from my email that looks like this:
Hello world
Med venlig hilsen
Marc Rasmussen
Besøg mig på MarcRasmussen.dk
However the body text is looks like this when taken from imap:
Hello world=0A=
=0A=
Med venlig hilsen=0A=
=0A=
Marc Rasmussen=0A=
=0A=
Bes=F8g mig p=E5 MarcRasmussen.dk =
is there any buildin method in PHP to fix this issue?
You have to check the Content-Transfer-Encoding header of the MIME part you are working on (hint: it's available in IMAP's BODYSTRUCTURE) and decode it yourself. The two most common encoding are quoted-printable and base64. See RFC 2045, chapter 6 for details.
You could try to use the $options parameter of the imap_fetchbody function. Maybe with flag FT_INTERNAL combined with utf8_encode:
$bodyText = utf8_encode(imap_fetchbody($this->imap,$i,1, FT_INTERNAL));
I hope it works for you!
$to= array();
foreach($users as $v) {
$to[(string)$v['address']] = (float)($v['amount']*100000);
}
$guid = "user";
$main_password = "pw";
$second_password = "pw2";
$fee = 60000;
$recipients = urlencode(json_encode($to));
$from = "address";
$note = "public";
$json_url = "https://blockchain.info/merchant/$guid/sendmany?password=".$main_password."&second_password=".$second_password."&recipients=".$recipients."&shared=false&fee=".$fee."¬e=".$note."&from=".$from;
echo $json_url;
die();
For some reason, when I echo $json_url;, the ¬e= is transformed to ¬e=. I can't find any PHP or HTML symbol that could be making that transformation.
That is ¬, or ¬ (mathematical not). Always use & to echo out an ampersand (even in URLs) if you're using HTML. Browsers are tolerant of sloppy coding, but in this case it can bite you.
**User_Tpl.html**
<html><head></head>
<body>
Hello {NAME},
Business name : {BUSINESS_NAME}.
Tel : {TELEPHONE}.
Mob : {MOBILE}.
</body>
</html>
function mailFooter($content) {
$sBusiness = 'Business name';
$sTelp = '0';
$sMobile = '0';
$content = str_replace('{BUSINESS_NAME}', $sBusiness, $content);
$content = str_replace('{TELEPHONE}', $sTelp, $content);
$content = str_replace('{MOBILE}', $sMobile, $content);
return $content;
}
$content = file_get_contents('page/email/User_Tpl.html');
$content = str_replace('{SUBJECT}', $subject, $content);
$content = str_replace('{NAME}', $ownerName, $content);
**mailerFooter($content);**
// always return {BUSINESS_NAME}, {TELEPHONE}
$mail->AddAddress( $email );
$mail->SetFrom($name );
$mail->AddReplyTo( $reply );
$mail->Subject = trim($subject);
$mail->MsgHTML( trim($content) );
$mail->IsHTML(true);
$mail->Send();
im using PHPMailer as Mailer library and how to replace those {strings} inside the mailFooter() function.
use array
$content ='
<html><head></head>
<body>
Hello {NAME},
Business name : {BUSINESS_NAME}.
Tel : {TELEPHONE}.
Mob : {MOBILE}.
</body>
</html>';
$search= array ('{BUSINESS_NAME}','{TELEPHONE}','{MOBILE}');
$replace=array($sBusiness,$sTelp,$sMobile);
$content =str_replace($search,$replace,$content);
private arr = array(
"{title}" => "Home page",
"{email}" => "my#mail.com",
...
);
private $content = "Title for my site - {title}, if you interesting my email addres -> {email}"
$this->content = strtr($this->content, $this->arr);
echo $this->content;
This return -> "Title for my site - Home page, if you interesting my email addres -> my#mail.com"
Hi we have a CRM System that needs to change SMTP server once updated by the admin.
We have a table that returns a set of data that contains the SMTP Settings that has a status of 1 needed. The problem is it still relays to the localhost smtp even i've sent the SMTP settings to the htmlMimeMail.php (class) Here is my code:
function sendEmail($txtFrom, $subject, $to, $cc = NULL, $bcc = NULL, $strHTML, $txtModel='')
{
$sql = "SELECT * FROM smtp_server WHERE status='1'";
$rstemp = $this->cn2->Execute($sql);
while(!$rstemp->EOF)
{
$SMTPid = $rstemp->fields['id'];
$SMTPServer = $rstemp->fields['server'];
$SMTPPort = $rstemp->fields['port'];
$SMTPusername=$rstemp->fields['user'];
$SMTPpass=$rstemp->fields['pass'];
$SMTPauth = $rstemp->fields['auth'];
$rstemp->MoveNext();
}
$rstemp->Close();
$fromEmail = $txtFrom;
$from = $fromEmail;
$mail = new htmlMimeMail();
$mail->setTextCharset('utf-8');
$mail->setHtmlCharset('utf-8');
$mail->setHeadCharset('utf-8');
$mail->setSMTPParams($SMTPServer, $SMTPPort,$SMTPid,base64_encode($SMTPusername),base64_encode($SMTPpass),$SMTPServer);
$mail->setReturnPath($fromEmail);
$mail->setFrom($from);
$mail->setSubject($subject);
$mail->setHTML($strHTML);
if(trim($txtModel) != '')
{
$file = strtoupper($txtModel).".pdf";
if(file_exists($this->dir.$file))
{
$attachment = $mail->getFile($this->dir.$file);
$mail->addAttachment($attachment, $file, "application/pdf");
}
}
if (!is_null($cc) && $cc != '')
{
//$arrEmail = explode(",", $cc);
$mail->setCc($cc);
//unset($arrEmail);
}
$mail->setBcc($bcc.', sample#email.com');
$arrEmail = explode(",", $to);
ini_set("SMTP",$SMTPServer);
$result = $mail->send($arrEmail);
return $result;
}
Am i missing something in my code?
I also added ini_set
Here is the function that receives the parameters.
function setSMTPParams($host = null, $port = null, $auth = null, $user = null, $pass = null,$helo = null)
{
if (!is_null($host)) $this->smtp_params['host'] = $host;
if (!is_null($port)) $this->smtp_params['port'] = $port;
if (!is_null($helo)) $this->smtp_params['helo'] = $helo;
if($auth == 4){
if (!is_null($auth)) $this->smtp_params['auth'] = true;
}else{
if (!is_null($auth)) $this->smtp_params['auth'] = false;
}
if (!is_null($user)) $this->smtp_params['user'] = $user;
if (!is_null($pass)) $this->smtp_params['pass'] = $pass;
}
Table definition
________________________________________
id|server |port|user|pass|auth |status
________________________________________
1 |localhost |25 |null|null|false|0
4 |somesmtp#mail.com|25 |user|pass|true |1
________________________________________
From what I can see, you sent the SMTP data to the class, but you neglected to tell the class to use that data:
$result = $mail->send( $a_to, 'smtp' )
Failing to set the second parameter in send results in the class defaulting to 'mail' as send type.
function send($recipients, $type = 'mail')
which then results in your system using the default PHP:
$result = mail($to, $subject, $this->output, implode(CRLF, $headers));
in the:
case 'mail':
of function send()
I'm not clear on why the setup resorted to the SMTP defaults that are set when htmlMimeMail class is launched, there may be some further modification of the code that creates that result, I can't say.
I realize this question is a bit old and the current htmlMimeMail won't run without errors on current PHP anyway, but figured might as well give an answer.