Jump to content


Photo

add an attachment to mail()


  • Please log in to reply
1 reply to this topic

#1 romio

romio
  • Members
  • PipPip
  • Member
  • 28 posts

Posted 15 March 2006 - 02:21 PM

This is my mail_sender.php which i use to get some values from a form and send to all subscribers...

<?php
require_once('config.inc.php');
$query = "select * from subscribers order by id";
mysql_select_db($database, $dbcnx);
$result = mysql_query($query) or die('Error, insert query failed');
$num_rows = mysql_num_rows($result);

if ((isset($_POST["MM_Mailer"])) && ($_POST["MM_Mailer"] == "subscribe")) 
{
            
            
            $subject_Form = $_POST['subject'];
            $message_Form = $_POST['message'];
            $email = $_POST['email'];

        while($row = mysql_fetch_array($result))
        {    
            $email = $row['email'];
            $headers .= "Miramare Beach Hotel"; 
            $headers .= "Content-Type: text/plain; charset=iso-8859-1\n";
            $recipient = $email;
            $subject = $message_Form;
            $message = $message_form;
            $msg = wordwrap( $msg, 1024 );
            mail($recipient, $subject, $message, stripslashes($msg), $headers);
        }
}        
        if(mail($recipient, $subject, $message, stripslashes($msg), $headers)) 
        {
            echo "<meta HTTP-EQUIV=\"REFRESH\" content=\"0; url='MailIsSend.php'\">";
        }
            else
            {
                echo "The message can not been sent !<br />\n";
            }
?>

But i need to add an attachment to my mail how can i do that?

Thanks.

#2 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 15 March 2006 - 02:34 PM

attachments are possibly the single most complex thing you can do with PHP mail() function, but after careful study of a tutorial like [a href=\"http://www.hollowearth.co.uk/tech/php/email_attachments.php\" target=\"_blank\"]this one[/a], you should have a pretty good base for getting it done.
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users