Results 1 to 3 of 3

Thread: Send mail in PHP

  1. #1
    Davisricky is offline Senior Member
    Join Date
    Dec 2009
    Posts
    331
    Rep Power
    3

    Default Send mail in PHP

    I am PHP developer. I am beginner in developer stage. I am working on one small website. In the web form I want to send mail to the admin person of website. I tried different code but none of them worked out. If you are having any solutions then reply me. It can helpful to me. Thanks in advanced.

  2. #2
    Garcíarobine is offline Senior Member
    Join Date
    Dec 2009
    Posts
    334
    Rep Power
    3

    Default

    Sending Mail from PHP Using SMTP– Example

    PHP mail() function

    You can be easily sent using the mail function. These functions have 4 arguments to send E-mails from a PHP web page. The parameters of this function are as follows:

    • Recipient E-mail address

    • E-mail Subject

    • E-mail message (body)

    • Headers and additional parameters like the Sender E-mail address

    Syntax:

    Code:
    mail( string to, string subject, string message [, string additional_headers [, string additional_parameters]] )
    Code:
    <?php
    //Check whether the submission is made
    if(isset()){    //Declarate the necessary variables
    =;
    =;
    =;
    =;     //Check for success/failure of delivery 
    if(mail(,,,"From:/r/nReply-to:"))
    echo "<span class='red'>E-mail has been sent successfully from  to </span>";
    else
    echo "<span class='red'>Failed to send the E-mail from  to </span>";
    }
    ?>

  3. #3
    Garcíarobine is offline Senior Member
    Join Date
    Dec 2009
    Posts
    334
    Rep Power
    3

    Default

    Try out this code, using this code you can Send Email with Attachment:

    Code:
    <?php 
     = 'test@example.com'; 
     = 'Test email with attachment'; 
     = md5(date('r', time())); 
     = "From: webmaster@example.comrnReply-To: webmaster@example.com"; 
     .= "rnContent-Type: multipart/mixed; boundary="PHP-mixed-".."""; 
     = chunk_split(base64_encode(file_get_contents('attachment.zip'))); 
    //define the body of the message. 
    ob_start(); //Turn on output buffering 
    ?> 
    --PHP-mixed-<?php echo ; ?>  
    Content-Type: multipart/alternative; boundary="PHP-alt-<?php echo ; ?>" 
    --PHP-alt-<?php echo ; ?>  
    Content-Type: text/plain; charset="iso-8859-1" 
    Content-Transfer-Encoding: 7bit
    Hello World!!! 
    This is simple text email message. 
    --PHP-alt-<?php echo ; ?>  
    Content-Type: text/html; charset="iso-8859-1" 
    Content-Transfer-Encoding: 7bit
    <h2>Hello World!</h2> 
    <p>This is something with <b>HTML</b> formatting.</p> 
    <?php 
    //copy current buffer contents into  variable and delete current output buffer 
     = ob_get_clean(); 
     = @mail( , , ,  ); 
    echo  ? "Mail sent" : "Mail failed"; 
    ?>

Similar Threads

  1. How to send e-mail through JSP
    By Erick Ballmer in forum Programming
    Replies: 3
    Last Post: 07-04-2010, 06:06 AM
  2. Send mail in ASP.net
    By MartinWilson in forum General Internet Terms
    Replies: 2
    Last Post: 06-22-2010, 01:45 PM
  3. Send mail from a Python script
    By ScottWright in forum Programming
    Replies: 0
    Last Post: 05-12-2010, 01:44 PM
  4. Send mail using VB.net
    By RogersNguyen in forum General Internet Terms
    Replies: 1
    Last Post: 05-07-2010, 01:52 PM
  5. Send mail using Gmail SMTP
    By Davisricky in forum Software Jargons
    Replies: 2
    Last Post: 02-13-2010, 02:04 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
SEO by SubmitEdge

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48