Jump to content

Php Mail Not Sending Results


newseed

Recommended Posts

I inherited a site that has a php email script embedded into a WP site. This seems to be a non-WP script. The issue is that the client receives a email notification when someone submits an email but the notification email comes blank.

 

Here's the html:

<form action="http://www.SITEURL.com/fb-html/mail.php" onsubmit="javascript:return validForm(document.mailinglist)" name="mailinglist" id="mailinglist">
<input  name="email" id="email"type="text" onblur="if (this.value == '') {this.value = 'Enter email address...';}" onfocus="if (this.value == 'Enter email address...') {this.value = '';}" size="20" value="Enter email address...">
<input type="image" class="button-ok" src="http://SITEURL.com/wp-content/themes/twentyten/images/mailing-button-ok.gif">
</form>

 

Here's the form action code (mail.php):

 

<?php

/* Set e-mail recipient info@SITEURL.com*/
$myemail  = "info@SITEURL.com";
$subject  = "Join Our Mailing List";
$headers = "From: SITE NAME Peace Movement <info@SITEURL.com>\r\n";
$from = "SITE NAME Peace Movement <info@SITEURL.com>";
/* Check all form inputs using check_input function */


/* Let's prepare the message for the e-mail */
$message = "Site name: SITE NAME
Your Mailing List form has been submitted by:
Email: $email
";
/* Send the message using mail() function */
mail($myemail, $subject, $message, $headers);
$myemail1=$_REQUEST['email'];
$subject="We're in this together!";
$headers = "From: SITE NAME Peace Movement <info@SITEURL.com>\r\n";//$headers = "From: SITE NAME <info@SITEURL.com>\r\n";
$from ="SITE NAME <info@SITEURL.com>";
$message = "<table width='100%' border='0' cellspacing='0' cellpadding='0' style='background:#183e69; font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#333; padding:0px; margin:0px;' height='100%'>
<tr>
   <td align='center' valign='top'> </td></tr>
 <tr>
   <td align='center' valign='top'>
   <table width='600' border='0' cellspacing='0' cellpadding='0' align='center' style='background:#fff;' >
 <tr>
   <td align='center' valign='top' style='padding:15px 0;'><a href='http://www.SITEURL.com/' target='_blank'><img src='http://www.SITEURL.com/fb-html/the-universal-flag-logo.jpg' alt='THE SITE NAME' width='433' height='98' border='0'></a></td>
 </tr>
 <tr>
   <td align='center' valign='top'><img src='http://www.SITEURL.com/fb-html/banner-img.jpg' width='568' height='267' alt='banner'></td>
 </tr>
 <tr>
   <td align='center' valign='top'> </td>
 </tr>
 <tr>
   <td align='left' valign='top'><table width='95%' border='0' align='center' cellpadding='0' cellspacing='0'>
     <tr>
       <td align='left' width='100%' valign='top'>
         <p style='padding:0px; margin:0px; line-height:20px; font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#333;  text-align: left;'>
           Dear Friend,<br>
           <img src='http://www.SITEURL.com/fb-html/universal-flag.jpg' width='164' height='164' align='right' alt='SITE NAME' style='float:right; margin:10px 0px 10px 15px;' />  <br>
           Welcome to the SITE NAME Peace Movement! We are a 501c3 non-profit collective, comprised of students, authors, environmentalists, musicians, artists, spiritual leaders, activists, mothers, fathers, and every day people...just like you
from around the globe. Together, we are working to bring about peace by reminding others...we are all connected.<br>
 <br>
           Want to get more involved in the SITE NAME Peace Movement?<br>
 <br>
           Please consider the following:<br>
 <br>

           </p>
         <table width='100%' border='0' cellspacing='0' cellpadding='0'>
           <tr>
            <td width='95%' align='left' valign='middle' style='font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#333;'>-      Like us on Facebook by visiting our page <a href='http://www.facebook.com/SITEURL' style='font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#0e7791; text-decoration: underline;' target='_blank'>here</a> - and suggest our page to your friends!</td>
             </tr>
           <tr>
             <td align='center' valign='top'> </td>
             <td align='left' valign='middle'> </td>
           </tr>           

             <td width='95%' align='left' valign='middle' style='font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#333;'>-      Follow us on Twitter by visiting our <a href='http://www.twitter.com/universal_flag' style='font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#0e7791; text-decoration: underline;' target='_blank'>Twitter</a> page</td>
             </tr>
           <tr>
             <td align='center' valign='top'> </td>
             <td align='left' valign='middle'> </td>
             </tr>
           <tr>

             <td width='95%' align='left' valign='middle' style='font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#333;'>-      
               Purchase a flag from our <a href='http://store.SITEURL.com' style='font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#0e7791; text-decoration: underline;' target='_blank'>online store</a> and share it with your friends, family, and community
               </td>
             </tr>
           <tr>
             <td align='center' valign='top'> </td>
             <td align='left' valign='middle'> </td>
             </tr>
           <tr>

             <td width='95%' align='left' valign='middle' style='font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#333;'>-      
               Write us at <a href='mailto:info@SITEURL.com' style='font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#0e7791; text-decoration: underline;'>info@SITEURL.com</a> to volunteer - we have lots of opportunities for people in every country! </td>
             </tr>
           <tr>
             <td align='center' valign='top'> </td>
             <td align='left' valign='middle'> </td>
             </tr>
           <tr>

             <td width='95%' align='left' valign='middle' style='font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#333;'>-      
               Become an affiliate and sell SITE NAMEs to earn money for your own organization - write <a href='mailto:info@SITEURL.com'  style='font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#0e7791; text-decoration: underline;'>info@SITEURL.com</a> for more info. </td>
             </tr>
           <tr>
             <td align='center' valign='top'> </td>
             <td align='left' valign='middle'> </td>
             </tr>
           </table>
         <p style='padding:0px; margin:0px; line-height:20px; font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#333; text-align:left;'>
           You'll be receiving periodic updates, invitations, and announcements about special deals and giveaway contests. We will never sell, rent or give your name or email address to anyone. And, you can always unsubscribe by clicking the link at the bottom of any future emails.<br>
 <br>
           Thanks again for registering. If you have any questions or comments, feel free to contact us.<br>
 <br>
 <br>
 <strong>Namaste,<br>
   Brian McClure & the SITE NAME community</strong><br>
 <br>
 <br>
           P.S. If you are not familiar with the meaning of the flag and symbol, you can find it <a href='http://www.SITEURL.com/about/' target='_blank' style='font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#0e7791; text-decoration: underline;'>here</a></p>
         </td>
       </tr>

     <tr>
       <td align='left' valign='top'> </td>
       </tr>
     <tr>
       <td align='left' valign='top'><img src='http://www.SITEURL.com/fb-html/heading-line-img.jpg' width='562' height='25' alt='heading'></td>
       </tr>
     <tr>
       <td align='left' valign='top'> </td>
       </tr>
     <tr>
       <td align='left' valign='top'><table width='100%' border='0' cellspacing='0' cellpadding='0'>
         <tr>
           <td width='38%' align='left' valign='middle'><a href='http://www.facebook.com/SITEURL' target='_blank'><img src='http://www.SITEURL.com/fb-html/facebook-img.jpg' alt='Facebook' width='137' height='42' border='0'></a></td>
           <td width='40%' align='left' valign='middle'><a href='http://twitter.com/Universal_Flag' target='_blank'><img src='http://www.SITEURL.com/fb-html/twitter-img.jpg' alt='Twitter' width='143' height='42' border='0'></a></td>
           <td width='22%' align='left' valign='middle'><a href='http://www.youtube.com/user/3SITEURL3' target='_blank'><img src='http://www.SITEURL.com/fb-html/youtube-img.jpg' alt='Youtube' width='97' height='42' border='0'></a></td>
           </tr>
         </table></td>
       </tr>
     <tr>
       <td align='left' valign='top'> </td>
       </tr>
     </table></td>
 </tr>
 </table>


   </td>
 </tr>
 <tr>
   <td align='center' valign='top'> </td>
 </tr>
 <tr>
   <td align='center' valign='top' style='font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#fff;'>©2012 SITE NAME Companies. All Rights Reserved</td>
 </tr>
 <tr>
   <td align='center' valign='top'> </td>
 </tr>
</table>

";
$headers  = "MIME-Version: 1.0\n";
	$headers .= "Content-type: text/html; charset=iso-8859-1\n";
	$headers .= "X-Priority: 3\n";
	$headers .= "X-MSMail-Priority: Normal\n";
	$headers .= "X-Mailer: php\n";
	$headers .= 'From: SITE NAME Peace Movement <info@SITEURL.com>'. "\r\n";
	$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

mail($myemail1, $subject, $message, $headers);
/* Redirect visitor to the thank you page */
header('Location: http://www.SITEURL.com');
exit();




//------------------------------------------------------------------------------------------
function formSelected( $var, $val )
{
   echo ( $var == $val ) ? "selected" : "";
}


//------------------------------------------------------------------------------------------
function formChecked( $var, $val )
{
   echo ( $var == $val ) ? "checked" : "";
}




/* Functions we used */
function check_input($data, $problem='')
{
   $data = trim($data);
   $data = stripslashes($data);
   $data = htmlspecialchars($data);
   if ($problem && strlen($data) == 0)
   {
       show_error($problem);
   }
   return $data;
}

function checkbox_values($checkbox_array) {
 $s = "";
 foreach ($checkbox_array as $c) {

   $s = $s . " " . $c;

 }
 return $s;
}

function show_error($myError)
{
?>
   <html>
   <body>

   <b>Please correct the following error:</b><br />
   <?php echo $myError; ?>

   </body>
   </html>
<?php
exit();
}
?>

 

Any help would be greatly appreciated.

Edited by Eddie
Link to comment
Share on other sites

One thing I noticed:

 

$headers  = "MIME-Version: 1.0\n";
               $headers .= "Content-type: text/html; charset=iso-8859-1\n";
               $headers .= "X-Priority: 3\n";
               $headers .= "X-MSMail-Priority: Normal\n";
               $headers .= "X-Mailer: php\n";
               $headers .= 'From: SITE NAME Peace Movement <info@SITEURL.com>'. "\r\n";
               $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

Looks like the last line in the $header's section is unnecessarily duplicated. Dunno if that would have anything to do with it though. Have you tried sending a simpler message, for example: "test", and seeing if that comes through?

 

Did this script recently stop working, or has it always not worked?

Link to comment
Share on other sites

Ben, I applied a new email script which works fine with the exception that it does not list the email.

 

I got this script from here.

 

Since I only need the Email address filled and sent, I stripped out all instances of the fields and logic that I don't need. Again, the only issue I have is the submitted email address does not appear but the label does.

 

Can you give the source a look per the link above and determine what I should comment out.

 

You know I've been doing web stuff for 9 years now and I have yet to jump into learning PHP like everything else. :(

I know just enough to plug things in but email scripts has never been my strong point.

Edited by Eddie
Link to comment
Share on other sites

No problem Ben. I have tried again but I can't seem to get past this issue with this script in any changes I make. It will either break or I cannot get the submitted email sent to a recipient. Out of the box it works fine but I don't need all those other fields.

*sigh*

Edited by Eddie
Link to comment
Share on other sites

I am totally oblivious that I cannot get a simple email form to send a one line field collecting a email address only.

 

Somebody please help me get it working. I tried using the one for W3C (link) with no success.

 

I just need a simple email collector with a secure way to prevent injections to the form and provide a way to redirect it to a preferred url after submission.

Link to comment
Share on other sites

I am trying to use this script from W3C

http://www.w3schools.com/php/php_secure_mail.asp

 

I using that form as is.

 

When I took over this site it had some kind of contact form plugin already but it was deactivated and so I am wondering if that didn't work either and possibly server/php conflict?

 

Oh, and the test form (the one above) is not within the WP (is in it's own folder) because I wanted to eliminate that WP is not the culprit.

Edited by Eddie
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...