Jump to content

add an attachment to mail()


romio

Recommended Posts

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

[code]
<?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";
            }
?>
[/code]

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

Thanks.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.