-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
Appearing invalid letters and characters #2941
Comments
What you're seeing is called quoted-printable encoding, and on the whole it should not be necessary on modern mail servers which allow 8-bit character sets in message bodies, and so don't usually need encoding. Issues can be caused by the PHP mail() function adding extra line breaks in unexpected places, and the best way to solve that is to avoid it by using SMTP to localhost instead, which you should be able to do by adding a call to Beyond that I'd need to see your script and the output you get with |
The key mistake I see there is setting the content transfer encoding in a custom header. PHPMailer will set that correctly for you, and by setting yourself it's likely to cause a conflict, resulting in the kind of confusion you're getting. I suggest you delete that line. |
sorry what line would be the transfer encoding? |
This one specifically:
I also noticed that all your other custom headers have line breaks in, but they are formatted incorrectly - |
it worked with these settings, thank you very much! I removed the line: and removed all the \r\n from the header |
That's good to hear. Generally speaking, PHPMailer tries to make things easier for you - if you find yourself doing fiddly things like adding line breaks or adding transfer encodings manually, you're probably doing more work than necessary! |
@Synchro I'm having the same problem again, but now the issue occurs when I attach a certificate to the email. When I remove the certificate, the problem doesn't happen. Have you seen anything similar with the certificate? Another detail is that in the variable "$aviso" there is a text. If I remove half of the text, it works, but with the entire text it doesn't work correctly. This is the remaining part of the code. |
Why are you manually setting the encoding to 7-bit when you have 8-bit content? That's not going to work, so I suggest you delete that line and let PHPMailer set the encoding for you. |
I've already done that, removed the 7bits, set it to 8bits, and left it empty. The issue is that when I don't set the encoding to 7bits, it gives an error of invalid signature. |
Apparently the issue lies with the signature itself; when removing the signature $mail->sign(), everything works perfectly. |
That's odd. I wonder if the signing process has trouble with UTF-8? |
@Synchro In this test I performed, the email was sent without a signature, and if you observe in the log, it contains strange characters, yet the email is received normally. However, when the signature is added, these characters are included in the email. |
The "strange characters" are normal quoted-printable encoding, which you can see is the designated encoding in the content-transfer-encoding header. Can you show how it looks with a signature? |
@Synchro Do you want me to capture the output of $mail->SMTPDebug = 2; with the signature? |
It's happening to me too, I don't know what to do anymore. Have any of you solved the problem? |
Yes. I'm guessing that something is messing up the MIME structure when signing a message, but I need an example of it failing to see what it's doing. |
This first one is an example with a signature 2024-02-05 17:06:21 SERVER -> CLIENT: 220 ###### Esqueceu a senha do seu usu=C3=A1rio? Ent=C3=A3o CLIQUE AQUI<= Qualquer d=C3=BAvida entre em contato c= Telefone:(19) ######## Obrigado! Favor n= AVISO LEGAL: Esta mensagem =C3=A9 desti= LEGAL ADVICE: This message is exclusively d= 2024-02-05 17:06:22 CLIENT -> SERVER: ------0835CFEDABC5312DD54C84F9A8A71063 2024-02-05 17:06:22 CLIENT -> SERVER: Content-Type: application/x-pkcs7-signature; name="smime.p7s" 2024-02-05 17:06:22 CLIENT -> SERVER: Content-Transfer-Encoding: base64 2024-02-05 17:06:22 CLIENT -> SERVER: Content-Disposition: attachment; filename="smime.p7s" 2024-02-05 17:06:22 CLIENT -> SERVER: 2024-02-05 17:06:22 CLIENT -> SERVER: MIIK+QYJKoZIhvcNAQcCoIIK6jCCCuYCAQExDzANBglghkgBZQMEAgEFADALBgkq 2024-02-05 17:06:22 CLIENT -> SERVER: hkiG9w0BBwGggggeMIIIGjCCBgKgAwIBAgIQUqa3VDWEe8qWJP+HcLDqZDANBgkq 2024-02-05 17:06:22 CLIENT -> SERVER: hkiG9w0BAQsFADB4MQswCQYDVQQGEwJCUjETMBEGA1UEChMKSUNQLUJyYXNpbDE2 2024-02-05 17:06:22 CLIENT -> SERVER: MDQGA1UECxMtU2VjcmV0YXJpYSBkYSBSZWNlaXRhIEZlZGVyYWwgZG8gQnJhc2ls 2024-02-05 17:06:22 CLIENT -> SERVER: IC0gUkZCMRwwGgYDVQQDExNBQyBDZXJ0aXNpZ24gUkZCIEc1MB4XDTIzMTIxOTE1 2024-02-05 17:06:22 CLIENT -> SERVER: MjY0NVoXDTI0MTIxODE1MjY0NVowggENMQswCQYDVQQGEwJCUjETMBEGA1UECgwK 2024-02-05 17:06:22 CLIENT -> SERVER: SUNQLUJyYXNpbDELMAkGA1UECAwCU1AxEzARBgNVBAcMCk1vZ2kgR3VhY3UxEzAR 2024-02-05 17:06:22 CLIENT -> SERVER: BgNVBAsMClByZXNlbmNpYWwxFzAVBgNVBAsMDjQ0NzY3MDkzMDAwMTUwMTYwNAYD 2024-02-05 17:06:22 CLIENT -> SERVER: VQQLDC1TZWNyZXRhcmlhIGRhIFJlY2VpdGEgRmVkZXJhbCBkbyBCcmFzaWwgLSBS 2024-02-05 17:06:22 CLIENT -> SERVER: RkIxFjAUBgNVBAsMDVJGQiBlLUNOUEogQTExSTBHBgNVBAMMQFVOSU1FRCBSRUdJ 2024-02-05 17:06:22 CLIENT -> SERVER: T05BTCBEQSBCQUlYQSBNT0dJQU5BIENPT1AgVFJBQkFMSE8gTUU6NDkyMTA5NjYw 2024-02-05 17:06:22 CLIENT -> SERVER: MDAxNDIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC9EYdBwPkXjREY 2024-02-05 17:06:22 CLIENT -> SERVER: KvdharWUSeeS8ZV3fu3CxyyCo1vm/eOcuP/1/nNMh22A5HbYOSR4pWeVPYbobYPf 2024-02-05 17:06:22 CLIENT -> SERVER: 46FRgcbzQUZmVSRduHWjOc54CBMr48TLxQWtthwJn3x+FC/dMU6pBr8tl/EdF/x8 2024-02-05 17:06:22 CLIENT -> SERVER: M+ufrURB4rlCiyWcFZULwyVA5G8u7hBW8U2fOT3M6478WMp7kx/FFCKMWFHMxIuU 2024-02-05 17:06:22 CLIENT -> SERVER: s7CqZgxu1uHA3R/RQzGwAa+SnEJbsNlRSv7+MIOpnNWb6wFgaUBJyURpEXRM8sL3 2024-02-05 17:06:22 CLIENT -> SERVER: BJ6HGwpUZe/IdafgaydkjbHzABFs6T9zqJaH5a0mFbW6pax/XQ6jc4QDqi+jCsmD 2024-02-05 17:06:22 CLIENT -> SERVER: jH6w6MO3AgMBAAGjggMHMIIDAzCBtgYDVR0RBIGuMIGroDgGBWBMAQMEoC8ELTA2 2024-02-05 17:06:22 CLIENT -> SERVER: MDMxOTUzMjAyOTU8rtfa25c8rrswMDAwMDAwMDAwMDAwMDAwMDAwMDAwMKAfBgVg 2024-02-05 17:06:22 CLIENT -> SERVER: TAEDAqAWBBRESUxWTyBGRVJSRUlSQSBMT1BFU6AZBgVgTAEDA6AQBA40OTIxMDk2 2024-02-05 17:06:22 CLIENT -> SERVER: NjAwMDE0MqAXBgVgTAEDB6AOBAwwMDAwMDAwMDAwMDCBGmdyYWNpZXRlQHVuaW1l 2024-02-05 17:06:22 CLIENT -> SERVER: ZGJ4bS5jb29wLmJyMAkGA1UdEwQCMAAwHwYDVR0jBBgwFoAUU31/nb7RYdAgutqf 2024-02-05 17:06:22 CLIENT -> SERVER: 44mnE3NYzUIwfwYDVR0gBHgwdjB0BgZgTAECAQwwajBoBggrBgEFBQcCARZcaHR0 2024-02-05 17:06:22 CLIENT -> SERVER: cDovL2ljcC1icmFzaWwuY2VydGlzaWduLmNvbS5ici9yZXBvc2l0b3Jpby9kcGMv 2024-02-05 17:06:22 CLIENT -> SERVER: QUNfQ2VydGlzaWduX1JGQi9EUENfQUNfQ2VydGlzaWduX1JGQi5wZGYwgbwGA1Ud 2024-02-05 17:06:22 CLIENT -> SERVER: HwSBtDCBsTBXoFWgU4ZRaHR0cDovL2ljcC1icmFzaWwuY2VydGlzaWduLmNvbS5i 2024-02-05 17:06:22 CLIENT -> SERVER: ci9yZXBvc2l0b3Jpby9sY3IvQUNDZXJ0aXNpZ25SRkJHNS9MYXRlc3RDUkwuY3Js 2024-02-05 17:06:22 CLIENT -> SERVER: MFagVKBShlBodHR45vf54d4v5df4vfddzzzxldXRyYWxjci5jb20uYnIvcmVwb3N 2024-02-05 17:06:22 CLIENT -> SERVER: dG9yaW8vbGNyL0FDQ2VydGlzaWduUkZCRzUvTGF0ZXN0Q1JMLmNybDAOBgNVHQ8B 2024-02-05 17:06:22 CLIENT -> SERVER: Af8EBAMCBeAwHQYDVR0lBBYwFAYIKwYBBQUHAwIGCCsGAQUFBwMEMIGsBggrBgEF 2024-02-05 17:06:22 CLIENT -> SERVER: BQcBAQSBnzCBnDBfBggrBgEFBQcwAoZTaHR0cDovL2ljcC1icmFzaWwuY2VydGlz 2024-02-05 17:06:22 CLIENT -> SERVER: aWduLmNvbS5ici9yZXBvc2l0b3Jpby9jZXJ0aWZpY2Fkb3MvQUNfQ2VydGlzaWdu 2024-02-05 17:06:22 CLIENT -> SERVER: X1JGQl9HNS5wN2MwOQYIKwYBBQUHMAGGLWh0dHA6Ly9vY3NwLWFjLWNlcnRpc2ln 2024-02-05 17:06:22 CLIENT -> SERVER: bi1yZmIuY2VydGlzaWduLmNvbS5icjANBgkqhkiG9w0BAQsFAAOCAgEAOOx7Zrff 2024-02-05 17:06:22 CLIENT -> SERVER: 2024-02-05 17:06:22 CLIENT -> SERVER: ------0835CFEDABC5312DD54C84F9A8A71063-- 2024-02-05 17:06:22 CLIENT -> SERVER: 2024-02-05 17:06:22 CLIENT -> SERVER: 2024-02-05 17:06:22 CLIENT -> SERVER: . 2024-02-05 17:06:22 SERVER -> CLIENT: 250 2.0.0 Ok: queued as 9CD734090D6F 2024-02-05 17:06:22 CLIENT -> SERVER: QUIT 2024-02-05 17:06:22 SERVER -> CLIENT: 221 2.0.0 Bye This one is without a signature: 2024-02-05 17:12:50 SERVER -> CLIENT: 220 #####.####.####.br Esqueceu a senha do seu usu=C3=A1rio? Ent=C3=A3o CLIQUE AQUI<= Qualquer d=C3=BAvida entre em contato c= Telefone:(19) ######### Obrigado! Favor n= AVISO LEGAL: Esta mensagem =C3=A9 desti= LEGAL ADVICE: This message is exclusively d= 2024-02-05 17:12:50 CLIENT -> SERVER: . 2024-02-05 17:12:50 SERVER -> CLIENT: 250 2.0.0 Ok: queued as 541504090D6F 2024-02-05 17:12:50 CLIENT -> SERVER: QUIT 2024-02-05 17:12:50 SERVER -> CLIENT: 221 2.0.0 Bye |
@Synchro I thought it was better to put it as an image because text gets disfigured. This first one is an example with a signature: This one is without a signature: |
@Synchro I managed to find out where the problem was, instead of using $mail->Body to write the message, use $mail->msgHTML(). |
That's odd, but I'm glad it's working for you! In the images, you can see that the signed one has a content transfer encoding of |
Hi, I'm having a problem sending email.
Strange letters are coming out in the middle of words, like C1, A1, A3...
When analyzing, I realized that it does this after a specific amount of characters.
I already converted to utf-8 and iso-8859-1 but without success
The text was updated successfully, but these errors were encountered: