Sending Attachments Using Email Function In Php

free web hosting
Open Discussion > CONTRIBUTE > Computers > Programming Languages > PHP Programming

Sending Attachments Using Email Function In Php

kvarnerexpress
I'm trying to send an attachment using the mail Php function.

It gets caught by the email server with an error. It seems to have a problem with the separator or who knows what. The server says something like "invalid separator on mime type."

The code is:

Code:

CODE
 // subject
$subject  = "Hello There ";

$mime_boundary = "<<<--==-->>>";

       // headers
       $headers  = "From: " . 'Tom' . " <" . 'texample@aol.com' . ">\r\n";
$headers .= "Return-Path: " . 'texample@aol.com' . "\r\n";
$headers .= "Reply-To: " . 'texample@aol.com' . "\r\n";
$headers .= "Content-type: Multipart/Mixed;\r\n";
$headers .= "Mime-Version: 1.0\r\n";
$headers .= "X-Mailer: PHP Mailer\r\n";
$headers .= " boundary=\"".$mime_boundary."\"";

// message
$message .= "This is a multi-part message in MIME format.\r\n";
$message .= "\r\n";
$message .= $mime_boundary."\r\n";

$message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";
$message .= "Content-Transfer-Encoding: 7bit\r\n";
$message .= "\r\n";
$message  = "Attached is the file ";
$message .= ".";
$message .= "\n\n";
$message .= $mime_boundary."\r\n";

$message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";
$message .= " name=\"feedback.txt\"\r\n";
$message .= "Content-Description: Requested File;\r\n";
$message .= " filename=\"feedback.txt\"\r\n";
$message .= "\r\n";
$message .= $mime_boundary."\r\n";

       $email = "dianne@aol.com";

// Send
if (mail ($email, $subject, $message, $headers)) {
   echo "<script>alert ('Your email was sent. ')</script>";
   }
else {  
   echo "<script>alert ('Unable to send your email.')</script>";
}  




I'm not trying to use the MimeMail class or anything since
the version of Php that we're using is not supported by it.
I'm just trying to do this using the mail function.

The code seems o.k. when compared to others that I have
seen. Can't figure out what's going on.

Thanks in advance for reading this and any suggestion or
solutions.
kvarnerexpress

 

 

 


Reply

round
asking a very stupid question but does the sever actually allow you to use mail functions, cause this one doesn't. I mean i have tons of scripts that i've used that work like a charm but you should look to php.net and see if there's anything there that will answer you question or fix your problem.round

Reply

moldboy
What do you mean the mail function isn't on this server? I've sent mail using php from trap17.
Anyway about your question, yes php.net, but more specificaly try:
http://ca3.php.net/manual/en/function.mail.php
scroll down to the part where the users post Vladimir has posted a message that may pertain to you.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Recent Queries:-
  1. send attachments in php - 8.53 hr back. (1)
  2. send attachment mail in wap - 14.14 hr back. (4)
  3. php send mail with attachment function - 16.19 hr back. (1)
  4. send email with attachment via php - 27.21 hr back. (1)
  5. php "email function" - 27.33 hr back. (1)
  6. phpmailer attachment index of/ - 33.56 hr back. (1)
  7. sending email with attachments using java script - 34.88 hr back. (1)
  8. send attachment with email using php mail funtion - 43.30 hr back. (1)
  9. processing form and attachment in php complete free source code - 46.57 hr back. (1)
  10. php send attachment - 47.20 hr back. (1)
  11. attachment in joomla based email submit form - 47.66 hr back. (1)
  12. create send attachment by email in javascript - 48.44 hr back. (1)
  13. php error sending zip attachment - 48.48 hr back. (2)
  14. php.net sending an email with attachment - 51.79 hr back. (1)
Similar Topics

Keywords : sending, attachments, email, function, php

  1. A Question About Php Mail
    A question about how php send mail using which email account in SMTP s (1)
  2. PHP Function To Add Previous and Next Page Feature
    useful php function (5)
    CODE <?php function navigationbar($start_number = 0, $items_per_page = 50,
    $count) {    // Creates a navigation bar    $current_page =
    $_SERVER["PHP_SELF"];     if (($start_number < 0) ||
    (! is_numeric($start_number))) {         $start_number = 0;     }
        $navbar = "";     $prev_navbar = "";     $next_navbar =
    "";     if ($count > $items_per_page) {         $nav_count = 0;
            $pag....
  3. Sending E-mails Based On Intervals?
    (7)
    Again, I need your help. I have two database entries, let's say "reg_users" and "news". The
    question is that if somethings was changed in the "news" database, the email letter will be sent
    automatically to all emails which are related to "reg-users" database. So, how can I accomplish this
    point. How can I set this process based on daily, weekly or monthly basis?....
  4. Sending E-mails After News Update?
    Coding needed?!? (8)
    I need the following code or the idea how to reach this concept. Let's say, I have a database
    entry which is called "news", where all of the news stories are stored. If this database entry got
    modified, like the new post was added to the web-site by an administrator, the registered users will
    get some kind of email notification automatically, I mean the mails are sent automatically without
    the interaction of someone else. ....
  5. Endif function?
    (6)
    As you get noticed before, I am studying PHP in examples like using the tutorials as well as books
    itself. Through my readings, I get this function CODE <?php endif; ?> a lot of times.
    So, what do you mean by this function, and what does it do exactly?....
  6. An Interesting Approach To Email Verification...
    (6)
    I was thinking just now and I came up with a very interesting solution for email verification.
    It's actually based off of how alot of spammers get your email: Dynamic images. You could have
    a dynamic image display in the email that activates the account when loading it. The only downfall
    to it is if your users are using a an email provider such as Gmail, the images will be blocked, but
    I have a solution for that too. You could have the image say "Congratulations your account has been
    activated". And then below the image in plain text write "If you do not see the....
  7. Php Email Validation
    A PHP data validation class with many functions (1)
    I've been reading through my old php book (PHP 4.1) and came across this data validation class.
    It can check a number of things ranging from telephone numbers , credit card number formats, email
    address and some others. I checked out some of the methods although I didnt expect it to work 100%
    because I've found source code errors thoughout the book and CD. I tested out a few of the
    methods to check and some of them did return expected results but some didnt either so the data
    validation class was not perfect and it didnt really bother me. The cool thing I found....
  8. Arrays Outside A Function
    Need to have arrays available to all functions. (3)
    I've got a bunch of arrays that i want to use for more then 1 function. when i declear the
    arrays outside a function i cant use it in a function. This code was originally written in
    javascript by another person but since I plan to use it and extend it with php I had to change it
    from javascript to php code. In the javascript code the arrays were decleared outside the functions
    with 'var arrayname' I read somewhere that declearing javascript variables with
    'var' gives it global access. Any ideas on how I can go about declearing 1 set of these
    arrays t....
  9. How To Check If Fsockopen Function Is Enabled?
    (2)
    Hi, I have VPS (virtual private server) and I have access to php.ini file. Is there any script that
    will show that fsockopen function is enabled or where do I have to enable it? Searched google and
    here and couldn't find anything. Thanks! ....
  10. Php Explode Function Help
    (4)
    I am having trouble creating a script, all i want to achieve is to: 1. Select the variable from my
    mysql database, which is in a format of : id|id|id|id| and so on... 2. Split them into separate
    variables by using : $songexploded = explode("|",$ttyo ); 3. Then this is the bit I'm
    stuck on trying to create a while loop from the $songexploded variables. So(this might not be
    correct but you should get the idea).. CODE $x=1; while ($songexploded
    ==$result) echo $songexploded[$x].'<br>'; }....
  11. Trouble With Phpbb Email
    (1)
    Hi guys, I want to know if there is anything you can do for sending confirmation email to your
    users automatically when they have just regeistered, when the host server does not support SMTP
    (Simple Mail Transfer Protocol). ? Thanks alot.....
  12. Sending $_get[] Variables To An Application
    (3)
    I'm trying to work out if it is possible to send variables to a application on server. E.g
    send the variable of id which is equal to 10 to an application - test.exe?id=10 Any ideas to see if
    this is possible?....
  13. The Best Zip Function
    (1)
    hi my 6th code is very useful, you can zip your file by this: CODE <? class dZip{     var
    $filename;     var $overwrite;          var $zipSignature =
    "\x50\x4b\x03\x04"; // local file header signature     var
    $dirSignature = "\x50\x4b\x01\x02"; // central dir header signature
        var $dirSignatureE= "\x50\x4b\x05\x06"; // end of central dir
    signature     var $files_count  = 0;     var $fh;          Function
    dZip($filename, $overwri....
  14. Mail() Clone
    A PHP mail() function clone (5)
    A lot of free web hosts have disabled the mail() function so you cannot send emails using PHP. Does
    anybody know of a script that makes a function "like" mail but is able to be installed in a web
    accessible directory and called included into another script and called like that? Or maybe you know
    how to make such a function? I just really need to find a way around the free hosts turning of the
    mail() function. I need to figure out a way to send emails.....
  15. Email Sending.
    email sending with php. (1)
    this script allow user to send an email for you. i hope you enjoy /wink.gif"
    style="vertical-align:middle" emoid=";)" border="0" alt="wink.gif" /> CODE
    [color="#0000ff"][indent]<?      $top='<html
    dir="rtl">      <head>   <meta http-equiv="Content-Language"
    content="fa">   <meta http-equiv="Content-Type" content="text/html;
    charset=utf-8">   </head>      <body>      <div
    align="center">       <p style="margin-top&....
  16. [php](simple) Using Functions To Combine Values In A Form
    Really simple example on how to combine values with function (2)
    I just learned this simple method on how to use functions to combine two values from a form. First
    we create ourselves a simple POST form CODE <form method="POST"> Name:
    <input type="text" name="nickname"> Location: <input
    type="text" name="location"> <input type="submit"
    value="Input"> </form> Now we add this php to that same file CODE
    <?php $nick = $_POST['nickname']; $location =
    $_POST['location' ....
  17. [php] Header Function
    (2)
    Header function Greetings we are going to use the header() funtion to redirect start making a
    file called page.php at the top of the file add CODE <?php ?> Example 1 After
    CODE header('Location: http://www.trap17.com'); the LOCATION means
    where you want it to go. Example 2 you also can define a file that you want to redirect to After
    CODE header('Location: index.php'); Example 3 you also can add a timer to
    it /laugh.gif" style="vertical-align:middle" emoid=":lol:" border="0" alt=....
  18. Error With Joomla Template
    cant find function (1)
    Hello! I am working on my template in Dreamweaver and i am using joomla extensions for
    dreamweaver! When i start my page with joomla stand alone server(jsas) i get this errors on the
    bottom of the page! QUOTE Warning:
    mosloadcomponent(w:/www/Joomla/components/com_banner/banner.php) : failed to open stream: No such
    file or directory in w:\www\Joomla\includes\frontend.php on line 66 Warning:
    mosloadcomponent(w:/www/Joomla/components/com_banner/banner.php) : failed to open stream: No such
    file or directory in w:\www\Joomla�....
  19. The Extract() Function
    Something I just found out (6)
    The extract() function is used in PHP to take an array and split it up into variables. MySQL
    queries can be parsed this way. Below is an example. CODE $query =
    mysql_query("select username, password from users where uid=1"); $result =
    mysql_fetch_array($query, mysql_assoc); extract($result); print "Your
    username is : $username"; The extract() function works for ANY array, including
    $_POST, and $_GET. Makes processing form data a LOT easier /biggrin.gif"
    style="vertical-align:midd....
  20. How Good Is This Data Cleaning Function?
    (2)
    Hi all, this is my first function and as part of a script and i just want to know a couple of
    things. here is the code for the function: CODE <? function
    clean($dirty_string) { $muddy_string = stripslashes($dirty_string);
    $murky_string = strip_tags($muddy_string); $clean_string =
    htmlentities($murky_string);      }; ?> So the first thing is how secure is
    it? the script this will be used in connects to a database and sends an email so it needs to stop
    SQL injections and any email ab....
  21. Add Users On Email Program With Php?
    (1)
    First of all Marry Christmas, Well so i am in some kind of a problem, i can't find out how to
    add users to my mail service, i have no idea what SMTP/IMAP program the server runs, neither does
    the system administrator. But it should be kinda the same thing for all of them if i am not wrong,
    Anyways i have full access to server so i can do whatever i want to do, i have SSH access too (Root
    access /rolleyes.gif" style="vertical-align:middle" emoid=":rolleyes:" border="0"
    alt="rolleyes.gif" /> )....
  22. Explode Function Help
    need help from you programmers! (1)
    /smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> Hi I am robert I
    need some help with some php coding. I am stuck with a explode function. Here is the code:
    $username = $check ; $query="SELECT `buildings` FROM `authuser` WHERE
    `uname` = '$username'"; $result=mysql_query($query);
    $result=mysql_result($result,0);
    list($building1,$building2,$building3,$building4,$building5,$building6
    ,$building7,$building8,$building9,....
  23. Email Header Inject Test
    (0)
    So I'm trying to write a script to check if someone is trying to do a header inject using my web
    based email form. The problem is that, regardless of the content, it is being tagged as hijacked.
    The following is the relevant part of my code: CODE $ip=$_POST['ip'];
            $httpref=$_POST['httpref'];
            $httpagent=$_POST['httpagent'];
            $visitor=$_POST['visitor'];
            $visitormail=$_POST['visitormail'];         $s....
  24. Phpnuke Newsletter Sending Problems
    (0)
    i have a problem sending newsletters....when i send them no1 receives it...i tried sending to the
    registered users on my site which im in and i didnt recieve it in my mail...i dont know why this is
    happening...it says the newsletter is sent...but we get nothing in our mail... heres the code
    QUOTE /************************************************************************/ /* PHP-NUKE:
    Web Portal System */ /* ===========================
    */ /* ....
  25. Wappymail_v1.50
    wap free mail/ email admin script :-) (15)
    Here is my new wap mail script. You can use it as a free email sending service or an email admin
    form (can set this option in config.php) its extremly simple to install and you will find full
    instructions in the zip file. Please feel free to comment, rate, or update this script :-)
    /tongue.gif" style="vertical-align:middle" emoid=":P" border="0" alt="tongue.gif" /> ....
  26. Include File.php?id=something
    using the include() function (13)
    Well, I am making a full CMS system for my site, and want to make the index.php file to include the
    view.php?id=1 file. I tried with this code, but it didn't work: CODE <?php include
    'view.php?id=1' ?> This is the error I get: CODE Warning:
    main(view.php?id=1) [function.main]: failed to open stream: Invalid argument
    in C:\server\xampp\htdocs\test\index.php on line 1 Warning:
    main() [function.include]: Failed opening 'view.php?id=1' for inclusion
    (i....
  27. How To Use A Link To Call Function In Php?
    (8)
    The title says it all, really. How do you call a function using in PHP? I'm doing a project
    and I stumbled upon this problem. I don't want to use query string in the href part like
    since that would mess up the other part of my code. Can anyone pleae help me? I've pasted the
    code below. /smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /> Thanksh.
    CODE <?php   function display($x){ //coding goes here.   } ?>
    <html> <body> <p align="center"> <a href="what g....
  28. Trouble With Emailer.php
    failed sending email error (6)
    Whenever someone registers at my forum, they get this error: Failed sending email :: PHP :: DEBUG
    MODE Line : 234 File : emailer.php however, the account will be sucessfully registered. It is
    weird because i did not change the original emailer.php at all. O__O||| anyone know whats up with
    it?....
  29. Getting List Of Directories And Files Using Php
    PHP Function for Directory and File List (6)
    is there a php function that lists the content of some folder.... example: /New folder new.txt
    left.gif download.zip dc.exe ....so is there..? /rolleyes.gif' border='0'
    style='vertical-align:middle' alt='rolleyes.gif' /> ....
  30. Email Form
    Very Simple (12)
    This is another little script that I devised. It's very simple. As the name suggests, it's
    a script that lets the user send an email via a form. CODE SENDMAIL.PHP echo "<form
    action='form-send.php' method='get'>"; echo "To: <input
    type='text' name='email' size=20>"; echo "Subject: <input
    type='text' name='title' size=20>"; echo "Message: <textarea
    cols=50 rows=25 name='message'></textarea>"; echo "<input typ....

    1. Looking for sending, attachments, email, function, php

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for sending, attachments, email, function, php

*MORE FROM TRAP17.COM*
advertisement



Sending Attachments Using Email Function In Php



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE