phpmailer - undefined letters in the body - php

I use the PHPMailer as my mail tool for a project. I should send to a user a letter which contains Romanian alphabet (the main difference from English letters is the fact of issue such letters as â, ă, î, ș, ț).
I set charset UTF-8 for my letter:
$mail->CharSet = 'UTF-8';
but it didn't help me. I see in Google mail signs ? instead â, ă, î, ș or ț.
How can I fix it?

Related

phpmailer does not work for Persian letters

I have a problem that the subject is printed for Persian letters like this:
تست
I changed Cherst to utf-8 but the problem was not resolved
body has no problem with Persian letters, the only problem is the subject
$phpmailer->Subject = '=?UTF-8?B?' . base64_encode($subject) . '?=';
Don't encode your subject yourself; it will interfere with PHPMailer's processing. To get PHPMailer to handle it for you, just do this:
$mail->CharSet = 'UTF-8';
After that make sure that all your other text processing is in UTF-8 (e.g. your database), and it will all work.

Use emoji in dynamic content body of HTML email in PHP

I have been trying to send an HTML email with PHPMailer containing emojis:
$mail = new PHPMailer();
$mail->isHTML(true);
$mail->CharSet = "UTF-8";
$mail->Subject = "😀 😃 😄 😁 😆 😅 😂 🤣 😊 😇 🙂 🙃 😉 😌";
$mail->Body = "😀 😃 😄 😁 😆 😅 😂 🤣 😊 😇 🙂 🙃 😉 😌";
However, the emojis are only displayed correctly in the subject; in the body, they are replaced by question marks (in Thunderbird and Outlook). The email does contain HTML, so just setting isHTML to false will not suffice. I have looked at Send unicode emoji with PHPMailer , but it does not seem to work for me, as the character set is already set to UTF-8. The content is user-generated (the user uses their own mobile keyboard to insert the emoji), so manually replacing every emoji with, for example, an image is not an option. Preferably the solution would be dynamic, so that new emojis also work whenever they come out.
you need to specify emoji's unicode value and try below method.
echo json_decode('"\uD83D\uDE00"');
Also you can use UTF-8 notation from this this table:
example:
😁 \xF0\x9F\x98\x81 GRINNING FACE WITH SMILING EYES

non-English characters display issue in gmail, yahoo via phpMailer class

I use phpMailer (as of today version in GitHub) to send automatic smtp activation mails from my noreply#host.com.
I tried it in gmail and yahoo. Both interpreted the characters as shown below.
nice unwanted (realized)
Ç -> Ç
ı -> Ä
ş -> Åž
mailing process order is:
"sign page" (has the form, utf-8 encoded), then
"assess_from_sign.php" (pure php without any encoding command. actual
sending or failure process is here),then
"inform page" (informs user for result)
my message in mail body starts with Dear $_POST['username']
What can I apply to $_POST['username'] variable in assess_from_sign.php page so even non-English characters seems exactly like in their own language.
note: all requests are redirecting to index.php page in my site and it has mb_internal_encoding("UTF-8"); command which applies to all pages.
thanks, regards
It's important that all aspects of the code is set to the same, specific charset. I recommend UTF-8 as you already started using, which covers most characters you'll ever need.
Below you'll find a "checklist" of what should be set to UTF-8.
PHP header - this has to be put prior to any output to the browser, and should be put on the top of all your .php pages: header('Content-Type: text/html; charset=utf-8');
HTML header - this should also be in all your pages containing HTML, and it to be put inside the <head> tags: <meta charset=utf-8" />
PHPMailer Object - specify the charset of your PHPMailer object by adding
$mail->CharSet = 'UTF-8';, where $mail is the object itself.
File-encoding: The file itself should be converted to a UTF8 charset (specifically UTF8 w/o BOM). This varies a bit on what kind of texteditor your are using, but in Notepad++ it's Format -> Convert to UTF8 (w/o Byte Order Mark).
There might be other aspects of your code that need to be set to an UTF8 charset (databases and such), but this should cover the mail-properties.
You can also reference UTF-8 all the way through.

PHPmailer cyrillic charset trouble

I think im doing things correct:
Im specifying charset of PHPMailer object: $mail->CharSet = "UTF-8";
Charsets of mail body and php script are UTF-8 too
But email arrives with this kind of errors (words are broken by black quarter with "?" symbol:
опреÐ �елени
оÑ �ибка определения
click to see the screenshot of example email
Update 1
Found something kinda chinese glyphs (but not cyrillyc symbols) in the email's source
Try:
$mail = new PHPMailer();
$mail->CharSet = 'UTF-8';
as staded by user2354947 in PHPMailer character encoding issues
the CharSet definition must be entered after the PHPMailer()
similar to my problem PHP ASCII to UTF-8 does not work
i found out that when you pull your data from sql, you need to transform it to UTF-8

Swift_Mailer + symfony UTF-8

I have an issue with Swift_Mailer in Symfony. I am sending e-mail messages in French which contain a lot of "à é è" characters. At first when i tried sending these characters came out fine in my email-client, but in my colleague's email-client they didn't.
So I put the text for the mail through a utf8_encode function and tried again. Now it is vica-versa. It shows fine in my email-client, but screwed up in my colleague's.
What is the best way to solve these e-mail UTF-8 issues with Swift_Mailer in Symfony?
Use $message->toString(); to see if your e-mail is well formatted, meaning everything is UTF-8 or uses the proper European ISO charset iso-8859-15. You can use setCharset to tell it what you're actually using.
The character set of the message (and it’s MIME parts) is set with the
setCharset() method. You can also change the global default of UTF-8
by working with the Swift_Preferences class.
Swift Mailer will default to the UTF-8 character set unless otherwise
overridden. UTF-8 will work in most instances since it includes all of
the standard US keyboard characters in addition to most international
characters.
It is absolutely vital however that you know what character set your
message (or it’s MIME parts) are written in otherwise your message may
be received completely garbled.
http://swiftmailer.org/docs/messages.html#setting-the-character-set

Categories