vbcoach Posted March 3, 2022 Share Posted March 3, 2022 Hello all. Need assistance on something I think should be a simple fix . I am using a PHP Mailer app on my website hosting, which is Network Solutions, I know, shame on me. Very recently Network Solutions stopped sending my HTML-encoded emails for some unknown odd reason. Using their PHP mail testing application, those emails with non-HTML are working and sending just fine, but as soon as I try to send one with HTML(isHTML=True) encoding, it never sends, but I also don't get an error. The program tells me the email was sent successfully. Can anyone help me out here? Quote Link to comment https://forums.phpfreaks.com/topic/314569-phpmail-stopped-sending-html-based-emails/ Share on other sites More sharing options...
ginerjm Posted March 3, 2022 Share Posted March 3, 2022 Assuming that Network Solutions is your host, I suppose that YOU are running the PHPMailer code from one of your own scripts. That said, what have you done to debug it? Quote Link to comment https://forums.phpfreaks.com/topic/314569-phpmail-stopped-sending-html-based-emails/#findComment-1594209 Share on other sites More sharing options...
vbcoach Posted March 3, 2022 Author Share Posted March 3, 2022 As you may already know, I do not have rights to edit the php.ini code as it is on a shared hosting site, but I will try your suggestion to add these two lines of code and see how the site reacts to it. I am using the pretty much standard PHPMail script. This script has served me well for the past 7-8 years or so and was working quite fine, actually. That is up until November of last year. The script still works, but only without HTML. Don't know if NetSol suddenly requires SMTP Auth now or what? Let me see what happens with your suggested changes... Quote Link to comment https://forums.phpfreaks.com/topic/314569-phpmail-stopped-sending-html-based-emails/#findComment-1594210 Share on other sites More sharing options...
ginerjm Posted March 3, 2022 Share Posted March 3, 2022 (edited) I didn't make any suggestions. Just wanted to know what you may have done to resolve this. Have you in fact made any changes since Nov. that may be unknowingly the cause of your problem? If not your fault, have you contacted Tech Support at your host to ask them? Sometimes when my host does an upgrade they leave out some settings in the ini file that cause me problems until I remind them that they left something out. Edited March 3, 2022 by ginerjm Quote Link to comment https://forums.phpfreaks.com/topic/314569-phpmail-stopped-sending-html-based-emails/#findComment-1594211 Share on other sites More sharing options...
vbcoach Posted March 3, 2022 Author Share Posted March 3, 2022 Yes for the past two days I have contacted numerous people over at Network Solutions, and all they want to do is send me over to their paid support a.k.a. "MyTime Support". My code hasn't changed a bit, but I am sure Network Solutions did some upgrades they didn't tell me about. Quote Link to comment https://forums.phpfreaks.com/topic/314569-phpmail-stopped-sending-html-based-emails/#findComment-1594212 Share on other sites More sharing options...
ginerjm Posted March 3, 2022 Share Posted March 3, 2022 I would change hosts. My provider is very good at resolving these kinds of issues when the problem could be their doing. You said that you are able to check the is html setting and confirm that you have it set or are setting it as you prep your message? Quote Link to comment https://forums.phpfreaks.com/topic/314569-phpmail-stopped-sending-html-based-emails/#findComment-1594213 Share on other sites More sharing options...
vbcoach Posted March 3, 2022 Author Share Posted March 3, 2022 Added the error reporting, no errors - says the HTML email was sent, but it never arrives. Quote Link to comment https://forums.phpfreaks.com/topic/314569-phpmail-stopped-sending-html-based-emails/#findComment-1594214 Share on other sites More sharing options...
ginerjm Posted March 3, 2022 Share Posted March 3, 2022 Can you send an html message to yourself? If not then I'd say it is NS's problem And you have issued "$mail->isHTML(true)" as part of your message setup? Quote Link to comment https://forums.phpfreaks.com/topic/314569-phpmail-stopped-sending-html-based-emails/#findComment-1594215 Share on other sites More sharing options...
vbcoach Posted March 3, 2022 Author Share Posted March 3, 2022 Yes, the isHTML(true) is part of the PHPMail script and my test-mail script. Only difference is that the test script has a checkbox to enable sending of mail using HTML. That's when it stops sending. Quote Link to comment https://forums.phpfreaks.com/topic/314569-phpmail-stopped-sending-html-based-emails/#findComment-1594219 Share on other sites More sharing options...
ginerjm Posted March 3, 2022 Share Posted March 3, 2022 I"m confused. If your script is setting html to true why do you have a checkbox doing it also? Are you handling the checkbox properly? Quote Link to comment https://forums.phpfreaks.com/topic/314569-phpmail-stopped-sending-html-based-emails/#findComment-1594220 Share on other sites More sharing options...
vbcoach Posted March 3, 2022 Author Share Posted March 3, 2022 I was saying that I was using two scripts. It's the Network Solution test-email.php script that has the HTML checkbox option. The PHPMail script I use to send the team receipt page emails already has HTML enabled. The script returns a message that the email is being sent as usual, but nothing is received via email. Quote Link to comment https://forums.phpfreaks.com/topic/314569-phpmail-stopped-sending-html-based-emails/#findComment-1594222 Share on other sites More sharing options...
ginerjm Posted March 3, 2022 Share Posted March 3, 2022 You are saying that the script (yours) you run on your host has an option and you are sure that you are handling the checkbox correctly? And that some other script that you run somehow does not have a checkbox but does have HTML turned on and it does or doesn't work? I am getting confused and this is getting frustrating. Quote Link to comment https://forums.phpfreaks.com/topic/314569-phpmail-stopped-sending-html-based-emails/#findComment-1594223 Share on other sites More sharing options...
vbcoach Posted March 3, 2022 Author Share Posted March 3, 2022 Let's take the confusion out of this, shall we? For years and years and years, I have been using the PHPMail script on github. Been working sending html emails for 7-8 years now without issue. It stopped sending last November. Something changed at NetSol and I don't know what it might be? Some security issue most likely? Network Solutions placed a test php mail script in my root folder years ago for testing. It was created by NetSol for NetSol accounts for testing purposes. That test script has various small options like using PHP Mail() or PEAR module, and also has a checkbox to enable sending as HTML. This script verified that PHPMail() is working. With HTML unchecked, the test email sends just fine, and I receive a message stating that the email has been sent successfully. With the HTML box checked? Same response, message sent successfully, but no HTML email is ever received. Hope this clears things up? What have I done? Remember, nothing in the original PHPMail script (or website) has been changed at all regarding the PHPMail module. In the TEST script, I tried auth-true and entered the un & pw, and still no HTML mail is ever received. This is why I came here. Why is HTML mail suddenly being blocked? Quote Link to comment https://forums.phpfreaks.com/topic/314569-phpmail-stopped-sending-html-based-emails/#findComment-1594224 Share on other sites More sharing options...
ginerjm Posted March 3, 2022 Share Posted March 3, 2022 (edited) So - a script that NS wrote 'years ago' and put onto your domain works when they run it (?) but not when you run it? That makes no sense. And why did they write this 'years ago'? I thought you were working fine up til Nov.? Edited March 3, 2022 by ginerjm Quote Link to comment https://forums.phpfreaks.com/topic/314569-phpmail-stopped-sending-html-based-emails/#findComment-1594225 Share on other sites More sharing options...
vbcoach Posted March 3, 2022 Author Share Posted March 3, 2022 Wow! We are just not on the same page here! The NS script is only a "test script" to verify that the PHP Mail() service is working. It send out a test email given the options you enter. If I "UNCHECK" the send using HTML box, the test script sends out a 'test' email properly and returns a message saying the email was sent successfully. If I "CHECK" the use HTML box, I still get the same message that the email was sent successfully, but no email is received. NetSol is obvioulsy blocking HTML emails from being sent somehow. I just can't figure out what they did on the backend to block HTML emails. Quote Link to comment https://forums.phpfreaks.com/topic/314569-phpmail-stopped-sending-html-based-emails/#findComment-1594226 Share on other sites More sharing options...
ginerjm Posted March 3, 2022 Share Posted March 3, 2022 Good luck. Sorry I couldn't help. Quote Link to comment https://forums.phpfreaks.com/topic/314569-phpmail-stopped-sending-html-based-emails/#findComment-1594228 Share on other sites More sharing options...
vbcoach Posted March 3, 2022 Author Share Posted March 3, 2022 Anyone else care to take a stab at this? Thanks for trying Ginerjm Quote Link to comment https://forums.phpfreaks.com/topic/314569-phpmail-stopped-sending-html-based-emails/#findComment-1594231 Share on other sites More sharing options...
dodgeitorelse3 Posted March 4, 2022 Share Posted March 4, 2022 why not post both scripts so we can try to remove more confusion? 1 Quote Link to comment https://forums.phpfreaks.com/topic/314569-phpmail-stopped-sending-html-based-emails/#findComment-1594236 Share on other sites More sharing options...
vbcoach Posted March 4, 2022 Author Share Posted March 4, 2022 Well what I did was to upgrade php from v5.6 to v7.4 and now nothing works, except for better error messages. <html> <head> <title>PHP Form Mail Test Script</title> </head> <body> <h3>PHP Form Mail Test Script</h3> <?PHP error_reporting(E_ALL); $email = $_REQUEST['email']; $body = $_REQUEST['body']; $subject = $_REQUEST['subject']; $from = $_REQUEST['from']; $sendusing = $_REQUEST['sendusing']; $usehtml = $_REQUEST['usehtml']; if ($sendusing == "mail") { $header = "From: " . $from . "\n"; if ($usehtml == "yes") $header .= "Content-Type:text/html\n"; else $header .= "Content-Type:text/plain\n"; if (mail($email, $subject, $body, $header)) echo "SUCCESS... Email sent using Mail() function";else echo "FAILED TO SEND!"; echo "<br>" . date('l dS \of F Y h:i:s A') . "<br><br>"; } else if ($sendusing == "pear") { if (mail_this($email, $subject, $body, $from)) echo "SUCCESS... Email sent to using PEAR module";else echo "FAILED TO SEND!"; echo "<br>" . date('l dS \of F Y h:i:s A') . "<br><br>"; } else { $email = "Type Email Address"; $body = "FormMail Test"; $subject = "Test Email"; $from = "custserv@networksolutions.com"; $sendusing = "mail"; } ?> <table><form method="post" action="" name="sendmailtest"> <tr><td>TO:</td><td><input value="<?PHP echo $email;?>" name="email" size="35"></td></tr> <tr><td>FROM:</td><td><input value="<?PHP echo $from;?>" name="from" size="35"></td></tr> <tr><td>Subject:</td><td><input value="<?PHP echo $subject;?>" name="subject" size="35"></td></tr> <tr><td colspan=2>Body:<br><textarea cols="45" rows="3" name="body"><?PHP echo $body;?></textarea></tr> <tr><td>Send Using:</td> <td><input name='sendusing' value='mail' type='radio'<?PHP if ($sendusing == "mail") echo " checked='checked'";?>><b>Mail() Function</b><br> <input name='sendusing' value='pear' type='radio'<?PHP if ($sendusing == "pear") echo " checked='checked'";?>><b>PEAR Module</b></td></tr> <tr><td>Use HTML <input name="usehtml" value="yes" type="checkbox"<?PHP if ($usehtml == "yes") echo " checked='checked'";?>></td> <td align=right><input name="submit" value="Send Email" type="submit"></td></tr> </form></table> <?PHP function mail_this($email, $subject, $body, $from) { include('Mail.php'); $headers['From'] = $from; $headers['To'] = $email; $headers['Subject'] = $subject; if ($usehtml == "yes") $headers['Content-type'] = "text/html"; else $headers['Content-type'] = "text/plain"; $params["host"] = "localhost"; $params["port"] = "25"; $params["auth"] = false; $params["username"] = "username"; $params["password"] = "password"; // Create the mail object using the Mail::factory method $mail_object =& Mail::factory('smtp', $params); $mail_object->send($email, $headers, $body); if (PEAR::isError($mail_object)) { return false; } else { return true; } } ?> </body> <!-- ####################################################### ## ## ## NOTE: This is a Network Solutions Test Script. ## ## Any modifications to this script are not the ## ## responsibility of Network Solutions as this script## ## was generated only to ensure that your service is ## ## functioning properly. ## ## ## ####################################################### --> </html> Anyone else care to take a stab at this? Thanks for trying Ginerjm Quote Link to comment https://forums.phpfreaks.com/topic/314569-phpmail-stopped-sending-html-based-emails/#findComment-1594248 Share on other sites More sharing options...
vbcoach Posted March 4, 2022 Author Share Posted March 4, 2022 Also, what I would like to do now since I have upgraded the PHP to v7.4 is to try the newer PHPMailer v5.6 or v6.x - but I am running a Windows website on NetSol shared hosting platform, so I do not have backend or command-line access like I do on a linux system. When I look at the PHPMailer code, I do not see files from the documentation like the PHPautoloader.php for example, nor do I see a folder called vendor anywhere? IU am kind of stumped at this point and really need some help with this ASAP! Thanks... Quote Link to comment https://forums.phpfreaks.com/topic/314569-phpmail-stopped-sending-html-based-emails/#findComment-1594249 Share on other sites More sharing options...
vbcoach Posted March 4, 2022 Author Share Posted March 4, 2022 So PHP 7.4 threw too many errors on my site, so I dropped down to PHP 7.0 Took care of other issues, but now on the test PHPMail script getting this error - I think it has something to do with the headers not being recognized? Warning: mail(): SMTP server response: 553 5.0.0 <custserv@networksolutions.com... Unbalanced '<' 500 5.5.1 Command unrecognized: "Content-Type:text/html>" in \\WDP\DFS\30\1\9\6\3007726691\user\sites\xxxxxx.site\www\mailer.php on line 19 FAILED TO SEND! Any thoughts? Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/314569-phpmail-stopped-sending-html-based-emails/#findComment-1594251 Share on other sites More sharing options...
dodgeitorelse3 Posted March 4, 2022 Share Posted March 4, 2022 (edited) ignore this please. Edited March 4, 2022 by dodgeitorelse3 sorry answered my own question after I re-read it. Quote Link to comment https://forums.phpfreaks.com/topic/314569-phpmail-stopped-sending-html-based-emails/#findComment-1594252 Share on other sites More sharing options...
Barand Posted March 4, 2022 Share Posted March 4, 2022 There are errors in your HTML markup. Put the table inside the form, instead of the form inside the table. The cell containing your textarea has a <td> but no closing </td> Quote Link to comment https://forums.phpfreaks.com/topic/314569-phpmail-stopped-sending-html-based-emails/#findComment-1594253 Share on other sites More sharing options...
gizmola Posted March 6, 2022 Share Posted March 6, 2022 Ok, let me clarify a few things for you. There is no such thing as phpmail. You are introducing confusion thinking that such a thing exists. PHP has a mail() function, which is somewhat configurable via the php.ini. By default it pipes mail input directly to whatever the local "Mail transfer agent" aka "MTA" is. The MTA is operating system dependent, but it's some server process that implements Simple Mail Transfer Protocol (SMTP) which is the protocol mail *servers* use to send and receive emails. Whether or not those emails actually get sent as expected or received, after mail has been called, has many complicated issues associated with it, and is the domain of experienced email system administrators. In your case, that is entirely within the purview of Network Solutions. I will offer just a few issues: To send email requires DNS, specifically MX records for a domain. In most cases systems are not sending email directly out of a specific application server. They instead are using the hosting companies email servers. To send email on behalf of a domain requires at very least SPF, and increasingly DKIM setups for the email servers on behalf of a domain The network solutions script is a red herring. We need to see what your script is doing. There are many ways to send email. We also need to understand more about these emails you send. What is the from address? Is it from you at your domain? What do the headers look like for the test emails you can send out? Is NS proxying your emails for you? What code packages the "html" version THe RFC's for how emails work has specific requirements for what an email is supposed to look like. An "html" email is not a replacement for a standard email. Technically an html email is just a attached version of the email that should be packaged with an original ascii only version. Email clients then will retrieve the html version and display that. Many email systems are highly fault tolerant, and not unlike the way browsers will tolerate broken html and still display something for you in most cases, that doesn't mean you should or your software should ignore the standard and correct format for emails. It is never correct to take code that would send an html email and then just add html tags to the body and send that instead, even if it has worked for you to some degree in the past. Some email systems will reject that email outright and you will likely never know that they were rejected. Some mail clients won't work or the email will look bad. Viewing html emails is actually a choice for the email client. Some people use clients that don't render html or they intentionally turn it off. That might be the minority, but it is another reason to have a properly constructed email. You really have a number of issues: You have limited control of your hosted environment? You aren't an expert on how email administration works or php You're running a really old script on a version of php that has been End of life for a long time You don't seem to have any test environment, so you're experimenting with your production environment, with limited visibility into that Apparently your script has some bugs, but again we haven't seen it, or any portion of it. To summarize. Yes you should use PHP 7.4 (at minimum). That is the *oldest* supported PHP version available. You might very well be better served by using one of the many current supported PHP mail libraries rather than something as low level and hosting dependent as mail(). For example, many libraries actually implement SMTP themselves, and give you a lot more control over the process of sending emails programmatically, while at the same time insuring that the delivered email data is actually compliant with email standards For any email sending you need a good handle on the questions I raised previously (how will you actually "send" email, in terms of what user@domain the email is coming from. Is this from your domain, and if so, is the email setup for the domain valid and workable. Anyone can setup something that "delivers" emails via smtp that will promptly be rejected or accepted and deleted with you never being the wiser. Here is an article talking about the best known php mailer libraries. The ones I would suggest considering are listed below. phpmailer https://github.com/PHPMailer/PHPMailer Probably this is the library you should use in renewing your existing email script. symfonymail https://symfony.com/doc/current/mailer.html This took over for the popular swiftmailer you may see mentioned as an alternative The php Composer tool was released a decade ago. There is no excuse left for a project that is not using composer to manage your dependencies. This is also why you probably need a dev/test environment within which you can run composer. Composer will download and manage your dependencies. It will build a standards compliant autoloader for your application that you include so that class libraries like phpmailer can be properly autoloaded Porting your email script is probably the path to getting something reliable and supported. I hope this helps you start moving yourself in the right direction. If you want to start answering some of the questions I posed, and need help and advice in doing so, feel free to follow up. Sending email seems simple but it has become a very complicated endeavor over the years, and like many things that seem simple on the surface, have a lot of hidden complexity to them, especially when things go wrong. 1 Quote Link to comment https://forums.phpfreaks.com/topic/314569-phpmail-stopped-sending-html-based-emails/#findComment-1594264 Share on other sites More sharing options...
Solution vbcoach Posted March 8, 2022 Author Solution Share Posted March 8, 2022 For anyone who might be reading this using the Network Solutions Shared Hosting platform, the ultimate fix was the mail server security was changed last November and required SSL/TLS now, even though they did not update their own documentation. Even their own technicians were not aware of this. The ultimate fix was upgrading PHPMailer to v6.6.0 and changing the port to 587 with TLS (on localhost) Quote Link to comment https://forums.phpfreaks.com/topic/314569-phpmail-stopped-sending-html-based-emails/#findComment-1594325 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.