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

Gmail 552-5.7.0 error when use file_get_contents to set mail body #2984

Closed
canerkoroglu opened this issue Nov 23, 2023 · 1 comment
Closed

Comments

@canerkoroglu
Copy link

canerkoroglu commented Nov 23, 2023

Problem description

I'm using phpmailer 6.5.3, i had gmail Gmail 552-5.7.0 error and using file_get_contents to get mail body , replace login details end send email via phpmailer.

Code to reproduce

my message body was like $body = file_get_contents("https://www.mysite.com/template/email.html");
contents of email.html

<html><head><style>h1 {color:red}</style></head><body><h1>Title</h1><br/><p>Login Details</p><p><strong>User:</strong> {{user}}</p><p><strong>Pass:</strong> {{pass}}</p><p><small>Thank you.</small></p></body></html>

Debug output

When i use file_get_contents over https://www.mysite.com/ phpmailer add some extra codes into body like that:

<script>(function(){var js =3D "window['__CF$cv$pa=
2023-11-23 09:15:01 CLIENT -> SERVER: rams']=3D{r:'82a84e201d3992dd',t:'MTcwMDczMDkwMC41MjYwMDA=3D'};_cpo=3Ddocum=
2023-11-23 09:15:01 CLIENT -> SERVER: ent.createElement('script');_cpo.nonce=3D'',_cpo.src=3D'/cdn-cgi/challenge-=
2023-11-23 09:15:01 CLIENT -> SERVER: platform/scripts/jsd/main.js',document.getElementsByTagName('head')[0].appe=
2023-11-23 09:15:01 CLIENT -> SERVER: ndChild(_cpo);";var _0xh =3D document.createElement('iframe');_0xh.height =
2023-11-23 09:15:01 CLIENT -> SERVER: =3D 1;_0xh.width =3D 1;_0xh.style.position =3D 'absolute';_0xh.style.top =
2023-11-23 09:15:01 CLIENT -> SERVER: =3D 0;_0xh.style.left =3D 0;_0xh.style.border =3D 'none';_0xh.style.visibil=
2023-11-23 09:15:01 CLIENT -> SERVER: ity =3D 'hidden';document.body.appendChild(_0xh);function handler() {var _0=
2023-11-23 09:15:01 CLIENT -> SERVER: xi =3D _0xh.contentDocument || _0xh.contentWindow.document;if (_0xi) {var _=
2023-11-23 09:15:01 CLIENT -> SERVER: 0xj =3D _0xi.createElement('script');_0xj.innerHTML =3D js;_0xi.getElements=
2023-11-23 09:15:01 CLIENT -> SERVER: ByTagName('head')[0].appendChild(_0xj);}}if (document.readyState !=3D=3D 'l=
2023-11-23 09:15:01 CLIENT -> SERVER: oading') {handler();} else if (window.addEventListener) {document.addEventL=
2023-11-23 09:15:01 CLIENT -> SERVER: istener('DOMContentLoaded', handler);} else {var prev =3D document.onreadys=
2023-11-23 09:15:01 CLIENT -> SERVER: tatechange || function () {};document.onreadystatechange =3D function (e) {=
2023-11-23 09:15:01 CLIENT -> SERVER: prev(e);if (document.readyState !=3D=3D 'loading') {document.onreadystatech=
2023-11-23 09:15:01 CLIENT -> SERVER: ange =3D prev;handler();}};}})();</script>

so this is strictly forbidden on gmail servers and i was getting the 552-5.7.0 error.

at the end i've solved problem that
replace file_get_contents("https://www.mysite.com/email/template.html");
with file_get_contents(DIR . "/email/template.html");

but my question is why php mailer adding this extra code into my e-mail body?

@Synchro
Copy link
Member

Synchro commented Nov 23, 2023

It's not. That content is coming from your site, not PHPMailer.

@Synchro Synchro closed this as completed Nov 23, 2023
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

2 participants