mail will not send attachment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Please help,

I need the body of this email to be sent as HTML and have the attachment go 
with it (a pdf from my HD) but it doesn't want to send.



R.

--------------------------------------------------------

<?php


 include ('connect.php');
   global $mail_to, $mail_cc, $mail_bcc, $mail_from, $mail_reply_to;
   global $mail_body, $mail_subject;
   global $userfile, $userfile_type, $userfile_name, $userfile_size;
   global $mail_type, $mail_headers, $mail_charset, $mail_encoding, $people;



if (isset($people)) {

if ($people == "everyone"){

   $query = "SELECT * FROM $table_name";
 $result= mysql_query($query);
 while ($row=mysql_fetch_array($result)) {
 $email_addresses[] = $row['email'];
 //$mail_to = "support@xxxxxxxxxxxxx";
  }
  }
 //$count = count($email_addresses);
//$mail_to = implode(', ', $email_addresses);
 /*this counts the number of entries

 echo $count;
 echo $recipients;*/

  if ($people == 2){

  //echo "by location";
  }

 if ($people == "byjob"){
  $mail_to = "ross@xxxxxxxxxxxxx";

  }

  }

 if (isset($SUBMIT)) {

  if (empty($mail_to)){
?>
<script>
  alert ('You have not entered the recipients email address')
  </script>
  <?
  }
  else { // send the mail

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";



   $mail_body = str_replace("\r\n", "<BR>", $mail_text);



   if(!empty($mail_from)) $mail_headers .= "From: $mail_from\n";
   if(!empty($mail_reply_to)) $mail_headers .= "Reply-to: $mail_reply_to\n";
   if(!empty($mail_cc))
            $mail_headers .= "Cc: " . str_replace(";", ",", $mail_cc) . 
"\n";
   if(!empty($mail_bcc))
            $mail_headers .= "Bcc: " . str_replace(";", ",", $mail_bcc) . 
"\n";

   $mail_subject = stripslashes($mail_subject);
   $mail_body = stripslashes($mail_body);




      $fp = fopen($userfile, "r");
      $file = fread($fp, filesize($userfile));
      $file = chunk_split(base64_encode($file));



 $mail_body = " <tr><td width=\"314\"><div align=\"center\"><img 
src=\"http://www.scottishsocialnetworks.org/ssn_logo3.gif\"; width=\"100\" 
height=\"139\"></div></td></tr>";
 $mail_body .= "<BR><BR><BR><BR>";
    $mail_body .= "<font size=\"2\" face=\"Verdana, Arial, Helvetica, 
sans-serif\">$mail_text </font>";
    $mail_body .= "<BR><BR><BR><BR><BR>";
    $mail_body .= "<tr>
    <td width=\"662\"><div align=\"center\"><font size=\"1\" face=\"Verdana, 
Arial, Helvetica, sans-serif\">55 Albany Street, Edinburgh, EH1 3QY, t: 0131 
524 9869, EXC 0131 557 4059, f: 0131 524 9860</font></div></td>
  </tr>
  <tr>
    <td width=\"662\"><div align=\"center\"><font size=\"1\" face=\"Verdana, 
Arial, Helvetica, sans-serif\">e: info@xxxxxxxxxxxxxxxxxxxxxxxxxx, Web: 
scottishsocialnetworks.org</font></div></td>
  </tr>";
  $mail_body .= "<BR>";
  $mail_body .= "<tr>
    <td width=\"662\"><div align=\"center\"><font size=\"2\" face=\"Verdana, 
Arial, Helvetica, sans-serif\">A project managed by the Rock Trust Charity 
No. SC018708 and supported by Communities Scotland</span></div></td>
  </tr>";



 mail( $mail_to, $mail_subject, $mail_body, $headers);
?>
  <script>
  alert ('Your email has been sucessfully sent')
  </script>
 <?
 }
 }












  ?>


<HTML>
<HEAD><TITLE>E-mailer</TITLE>
<script>
function ddd() {
document.ross.submit()
}
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd";>
<html><!-- InstanceBegin template="Templates/ssn.dwt" 
codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- InstanceBeginEditable name="doctitle" -->
<title>Untitled Document</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<style type="text/css">
<!--
.style6 {font-family: Arial, Helvetica, sans-serif; font-size: 12px;}
-->
</style>
<!-- InstanceEndEditable -->
<style type="text/css">
<!--
.style1 {font-size: 12px}
.style7 {font-size: 10; }
.style8 {font-size: 9px; }
-->
</style>
<link href="ssn.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body,td,th {
 font-family: Arial, Helvetica, sans-serif;
 font-size: 12px;
 color: #000000;
}
body {
 margin-left: 0px;
 margin-top: 0px;
 margin-right: 0px;
 margin-bottom: 0px;
}
-->
</style></head>

<body>
<table width="950" height="506" border="0" align="center" cellpadding="0" 
cellspacing="0">
  <tr>
    <td width="126" height="355" align="left" valign="top"><table 
width="126" border="0" align="center" cellpadding="5">
        <tr>
          <td><img src="ssn_logo3.gif" width="100" height="139"></td>
        </tr>
        <tr>
          <td width="116"><div align="center"><a href="mailer.php">Mail a 
newsletter </a></div></td>
        </tr>
        <tr>
          <td><div align="center"><a href="add_contact.php">Add a new 
contact</a> </div></td>
        </tr>
        <tr>
          <td><div align="center"><a href="editor.php">Edit Database</a> 
</div></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
    </table></td>
    <td width="894" valign="top"><div align="center">
        <!-- InstanceBeginEditable name="EditRegion3" -->
        <FORM ACTION="<?php $PHP_SELF; ?>" METHOD="POST" 
ENCTYPE="MULTIPART/FORM-DATA" name="ross" id="ross">
          <div align="left">
            <p>
              <INPUT TYPE="HIDDEN" NAME="action" VALUE="send_mail">
            </p>
            <p>&nbsp; </p>
          </div>
          <table width="707" border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td width="697"><TABLE WIDTH="100%" BORDER="0" align="left" 
CELLPADDING="5" CELLSPACING="2">
                  <TR>
                    <TH WIDTH="16%" rowspan="2" ALIGN="CENTER"><div 
align="right"><span class="style6">To</span></div></TH>
                    <TD WIDTH="42%" rowspan="2"><textarea name="mail_to" 
cols="60" rows="5" class="style6"><?=$mail_to; ?>
          </textarea>
                    </TD>
                    <TD WIDTH="42%" align="left" valign="top"><select 
name="people" id="people" onChange="javascript:ddd()">
                        <option>Please Select</option>
                        <option value="everyone"<?php if($people == 
'everyone')
{ ?> selected<?php } ?>>Everyone</option>
                        <option value="byjob"<?php if($people == 'byjob')
{ ?> selected<?php } ?>>by job</option>
                        <option value="byarea"<?php if($people == 'byarea')
{ ?> selected<?php } ?>>by Area</option>
                      </select>
                        <input type="submit" name="Submit" value="Submit">
                    </TD>
                  </TR>
                  <TR>
                    <TD><?php  if ($people == 2){
    ?>
                        <select name="select">
                          <option>West</option>
                          <option>East</option>
                          <option>South</option>
                          <option>North</option>
                        </select>
                        <?
}
?>
                    </TD>
                  </TR>
                  <TR>
                    <TH ALIGN="CENTER" WIDTH="16%"><div align="right"><span 
class="style6">Cc</span></div></TH>
                    <TD colspan="2"><textarea name="mail_cc" cols="60" 
class="style6" disabled="yes"></textarea></TD>
                  </TR>
                  <TR>
                    <TH ALIGN="CENTER" WIDTH="16%"><div align="right"><span 
class="style6">Attachment</span></div></TH>
                    <TD colspan="2"><INPUT TYPE="FILE" NAME="userfile"></TD>
                  </TR>
                  <TR>
                    <TH ALIGN="CENTER" WIDTH="16%"><div align="right"><span 
class="style6">Type</span></div></TH>
                    <TD colspan="2"><INPUT TYPE="RADIO" VALUE="text" 
NAME="mail_type">
                        <span class="style6">TEXT</span>
                        <INPUT NAME="mail_type" TYPE="RADIO" VALUE="html" 
checked>
                        <span class="style6">HTML</span></TD>
                  </TR>
                  <TR>
                    <TH ALIGN="CENTER" WIDTH="16%"><div align="right"><span 
class="style6">Subject</span></div></TH>
                    <TD colspan="2"><INPUT NAME="mail_subject" 
class="style6" SIZE="40"></TD>
                  </TR>
                  <TR>
                    <TH WIDTH="16%" ALIGN="CENTER" valign="top"><div 
align="right" class="style6">Message</div></TH>
                    <TD colspan="2"><TEXTAREA NAME="mail_text"
         COLS="70" ROWS="16" class="style6"></TEXTAREA></TD>
                  </TR>
                  <TR>
                    <TH ALIGN="CENTER">&nbsp; </TH>
                    <TH colspan="2" ALIGN="CENTER"><div align="right">
                        <input name="submitted" type="hidden" 
id="submitted">
                        <INPUT TYPE="SUBMIT" VALUE="Send" NAME="SUBMIT">
                        <INPUT TYPE="RESET" VALUE="Reset" NAME="RESET">
                    </div></TH>
                  </TR>
              </TABLE></td>
            </tr>
          </table>
          <DIV ALIGN="CENTER "></DIV>
        </FORM>
        <!-- InstanceEndEditable --></div></td>
  </tr>
</table>
</body>
<!-- InstanceEnd --></html>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux