SkyRanger Posted June 23, 2019 Share Posted June 23, 2019 Email will send with the #$body but will not send with the $body = str_replace $the_kudo_image = '<img src=' . $kudobanner . '>'; $dir = plugin_dir_path( __DIR__ ); $template = file_get_contents( $dir .'/partials/kudos-email-template.html'); $emtemp = $dir .'/kudos/admin/partials/kudos-email-template.html'; $body = str_replace( array( '{kudos_link}', '{the_kudo_image}', '{kudoagent}', '{kudoclient}', '{agentloc}', '{kudoposted}', '{kudomsg}' ), array( $kudos_link, $the_kudo_image, $kudoagent, $kudoclient, $agentloc, $kudoposted, $kudomsg ), $template ); #$body = "testing email"; //commented out due to test body $to = "daveellis@eastlink.ca"; $subject = "Kudos for $kudoagent"; $headers = array('Content-Type: text/html; charset=UTF-8'); $headers .= 'From = Kudo Server <noreply@aciwork.cloudaccess.host>'; $mail = @wp_mail( $to, $subject, $body, $headers ); if($mail) { echo "<p>Mail Sent.</p>"; } else { echo "<p>Mail Fault.</p>"; } Quote Link to comment Share on other sites More sharing options...
gw1500se Posted June 23, 2019 Share Posted June 23, 2019 First, you should be using PHPMailer. It is much easier and has better control. What does the template contain? Did you print out what you read to make sure it is what you expect? Quote Link to comment Share on other sites More sharing options...
gw1500se Posted June 23, 2019 Share Posted June 23, 2019 (edited) 1 minute ago, gw1500se said: First, you should be using PHPMailer. It is much easier and has better control. What does the template contain? Did you print out what you read to make sure it is what you expect? What does "will not send" mean? It is not sending the email at all or is the sent email blank? Edited June 23, 2019 by gw1500se Quote Link to comment Share on other sites More sharing options...
ginerjm Posted June 23, 2019 Share Posted June 23, 2019 As mentioned already you should be dumping out some of the vars to be sure they contain what you think they should. Also - do you have php error checking on just to catch some errors you may have? Such as $headers. You first create it as an array but then you append a string to it. I have no idea what you might have at that point so a var_dump of that would be important. And - don't use the @ sign to suppress things. If there is an error you should be handling it! Plus the From assignment is incorrect (I believe). It should be "From: xxx" not "From = xxx". Quote Link to comment Share on other sites More sharing options...
SkyRanger Posted June 23, 2019 Author Share Posted June 23, 2019 Thanks guys, yeah forgot about the @ and yeah the $headers was incorrect. They have been fixed but pulling no errors, template it populating properly as it is suppose and stating the email has been sent but not receiving. Not sure if receiver server or outbound is blocking it. or it is just stating it is sending but not sending. Quote Link to comment Share on other sites More sharing options...
SkyRanger Posted June 24, 2019 Author Share Posted June 24, 2019 This is the template file: kudos-email-template.html and everythings shows correctly on check. Also going to check out phpmailer <html> <head> <meta content="en-ca" http-equiv="Content-Language" /> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Untitled 3</title> <style type="text/css"> .auto-style1 { text-align: center; } </style> </head> <body> <table style="width: 100%"> <tr> <td class="auto-style1">View Online</td> </tr> <tr> <td><img src="buslogo.png" width="94" alt="" style="border-width:0; max-width:94px;height:auto; display:block" /></td> </tr> <tr> <td> </td> </tr> <tr> <td class="auto-style1">{kudomsg}</td> </tr> <tr> <td> </td> </tr> <tr> <td> <div style="color:#4b4f55; font-size:16px; margin-top: 60px; margin-bottom: 40px; text-align:left; font-family: Verdana, Geneva, sans-serif"> <div> {kudoagent} </div> <div> {kudoclient} </div> <div> {agentloc} </div> <div> {kudoposted} </div> </div> </td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> </table> </body> </html> Quote Link to comment Share on other sites More sharing options...
SkyRanger Posted June 24, 2019 Author Share Posted June 24, 2019 I installed a mail logger/checker. It is also showing no errors. Going to contact my service provider to see if it is being blocked on the server side. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted June 24, 2019 Share Posted June 24, 2019 Are you able to send just a simple text email with a simple "hello world" message in it instead of all this other stuff? Testing the ability to send emails is priority one now I think. Quote Link to comment Share on other sites More sharing options...
SkyRanger Posted June 24, 2019 Author Share Posted June 24, 2019 Found out the problem. It is my ISP that is blocking the emails. The mail guard program they are using is blocking the emails due to a url. I have contacted them and they have fixed the issue. HTML emails are working now. Quote Link to comment 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.