Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If we use 'XYZ & Contracting Company' in subject this is sent as 'XYZ &amp Contracting Company'. Please suggest how to fix #3001

Closed
sierracbe opened this issue Jan 3, 2024 · 2 comments

Comments

@sierracbe
Copy link

sierracbe commented Jan 3, 2024

Problem description

If we use 'XYZ & Contracting Company' in subject this is sent as 'XYZ &amp Contracting Company'. Please suggest how to fix

Code to reproduce

........

    $intro_mail = new PHPMailer\PHPMailer\PHPMailer();
$intro_mail->CharSet = "UTF-8";

$intro_mail->isSMTP();

$intro_mail->Host = $host;
$intro_mail->Username = $smtpusername;
$intro_mail->Password = $smtppassword;
$intro_mail->SMTP_PORT=$port;
$intro_mail->SMTPSecure = $smtpsecure;			
$intro_mail->SMTPAuth = true;     // turn on SMTP authentication

$intro_mail->From=$fromid;
						
$intro_mail->FromName = $fromname;

$intro_mail->IsHTML(true);  
    $companyname="XYZ & Contracting Company";
$intro_mail->Subject=$companyname." - ".$message_title_intro;
@sierracbe sierracbe changed the title If we use 'Bazy Trading & Contracting Company' in subject this is sent as 'Bazy Trading &amp Contracting Company - eFACiLiTY – Enquiry'. Please suggest how to fix If we use 'Bazy Trading & Contracting Company' in subject this is sent as 'Bazy Trading &amp Contracting Company'. Please suggest how to fix Jan 3, 2024
@sierracbe sierracbe changed the title If we use 'Bazy Trading & Contracting Company' in subject this is sent as 'Bazy Trading &amp Contracting Company'. Please suggest how to fix If we use 'xxx & Contracting Company' in subject this is sent as 'xxx &amp Contracting Company'. Please suggest how to fix Jan 3, 2024
@sierracbe sierracbe changed the title If we use 'xxx & Contracting Company' in subject this is sent as 'xxx &amp Contracting Company'. Please suggest how to fix If we use 'XYZ & Contracting Company' in subject this is sent as 'XYZ &amp Contracting Company'. Please suggest how to fix Jan 3, 2024
@Vijay-Chaudhary
Copy link

$subject = 'XYZ & Contracting Company';
$encodedSubject = mb_encode_mimeheader($subject, 'UTF-8', 'Q');
Hi @sierracbe , You can try mb_encode_mimeheader php method for more specific encoding

@Synchro
Copy link
Member

Synchro commented Jan 7, 2024

No, don't do that, you're only going to cause problems with that as it's duplicating what PHPMailer already does, so you're likely to end up with double or corrupt encoding.

PHPMailer does not apply HTML entity encoding anywhere except debug output, so it's not PHPMailer that's doing this.

@Synchro Synchro closed this as completed Jan 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants