PHPMailer Body gets truncated -
i'm having strange issues phpmailer. i'm trying send content generate php in html , plain text, body gets truncated. what's stranger happens email generate, if put in there generic content in greater length, gets sent properly. must mention, did echo content of both $content
, $nohtmlcontent
variables , there should be, when receive email mailbox, it's truncated.
my php code creating plain text , html email body:
$content="<body bgcolor=\"#ffffff\"><font face=\"verdana\" size=\"2\">"; $content.="hello $name.<br /><br />administrator of <a href=\"http://$url\">$url</a> has created new account you.<br /><br />your new account details:<br />"; $content.=$message."<br /><br />"; $content.="if see wrong, please reply correct details , update account.<br /><br />"; $content.="have nice day,<br />$url</font></font></body>"; $nohtmlcontent="hello $name.\n\nadministrator of $url has created new account you.\n\nyour new account details:\n\n"; $nohtmlcontent.=$usremail."\n\n"; $nohtmlcontent.="if see wrong, please reply correct details , update account.\n\n"; $nohtmlcontent.="have nice day,\n$url";
all variables populated proper data.
my phpmailer code sending email:
require_once("class.phpmailer.php"); $mail=new phpmailer(true); try { $mail->addaddress($email); $mail->setfrom('admin@example.com', 'example.com'); $mail->charset = 'utf-8'; $mail->subject = "new account you"; $mail->ishtml(true); $mail->altbody = $nohtmlcontent; $mail->body = $content; $mail->send(); return true; }catch(phpmailerexception $e){ trigger_error("phpmailer failed: ".$e->errormessage()); return false; }
result:
hello 12 23. administrator of admin.localhost.dev has created new account you. new account details: username: user1 password: 123456 e-mail address: info@tourazore.com subscription status: not verified (you must verify email address before can use account) package: free (limitations: 1 tour, 5 items) first name: 12 last name: 23 city 34 country 45 verification link: http://admin.localhost.dev/verify-account/882672636ce2ad8c498f75a9b836ff055aecf573/ if see wrong, please reply correct details , update
expected result:
hello 12 23. administrator of admin.localhost.dev has created new account you. new account details: username: user1 password: 123456 e-mail address: info@tourazore.com subscription status: not verified (you must verify email address before can use account) package: free (limitations: 1 tour, 5 items) first name: 12 last name: 23 city 34 country 45 verification link: http://admin.localhost.dev/verify-account/882672636ce2ad8c498f75a9b836ff055aecf573/ if see wrong, please reply correct details , update account. have nice day, admin.localhost.dev
please notice content in end.
i have tried using php's function mail()
send same content, gets truncated.
any ideas?
solution: php code generated long line, after adding few newline characters, complete content got through.
also may not related you're using body , not msghtml
$mail->body = $content;
but looks using html expressions in content.
i'm new i've read use html in phpmailer should use
$mail->msghtml = $content;
although text looks likes displaying fine , solved problem. thought i'd share incase helps.
some useful info here https://phpbestpractices.org/ (scroll down email info)
and here: https://github.com/phpmailer/phpmailer
Comments
Post a Comment