I am sending email using PHPMailer.
I want to send price in subject, e.g "Bid of Price 460 € has been placed".
I used € and € in subject but it doesn't display properly. It shows &euro
instead incase of €
What should I use to solve this?
Here is my code:
$mail = new PHPMailer(true);
$mail->IsMail();
$body = $mailBody;
$mail->CharSet = "text/html; charset=UTF-8;";
$mail->IsHTML(true);
$mail -> AddAddress( $email, '' );
$mail -> SetFrom( '[email protected]', 'Support Fretbay.com');
$mail -> Subject = 'Bid of Price 460 € has been placed';
$mail -> AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
$mail -> MsgHTML($body);
$mail -> Send();
In the "Send mail as," click Add another email address. In the window that opens, enter the name you want recipients to view. Enter the email address alias you've set up for email forwarding. Confirm that "Treat as an alias" is marked, and click Next step.
Subjects can't contain html entities, so €
won't work. You have to use charset that contains euro symbol, and set $mail->CharSet
property. And sure, your €
char must use this charset too:
$mail->CharSet = "UTF-8";
$mail->Subject = 'Bid of Price 460 € has been placed';
Its important that the euro sign is UTF-8 to be displayed correctly.
A simple solution is to use mb_encode_mimeheader, to be 100% sure.
$subject = "Here is €500!";
$subject = str_replace('€', mb_encode_mimeheader('€', 'UTF-8'), $subject);
Works well with PHPMailer and PEAR::Mail
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With