Results 1 to 10 of 10

Thread: Send Email by SMTP

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Location
    United States
    Posts
    157

    Angry Send Email by SMTP

    Hello

    How can I send an email by SMTP?
    I need a PHP sample.
    Please help me to get it.


    Thank you
    Last edited by onh1986; Jan 5th, 2006 at 07:28 PM.

  2. #2
    Hyperactive Member ninjanutz's Avatar
    Join Date
    Jun 2005
    Location
    Bayside
    Posts
    256

    Re: Send Email by SMTP

    mail ($_POST['email'], 'subject of email here', 'body of email here', 'From: ur email here');

    u have to make sure mail is enabled in the php ini file though

  3. #3
    Hyperactive Member PlaGuE's Avatar
    Join Date
    Jun 2005
    Location
    in ur mind.
    Posts
    445

    Re: Send Email by SMTP

    you should do more then that. As that will get rejected by some servers.

    PHP Code:
    $to "[email protected]";
           
    $subject "You've won 1000$";
           
    $message="This is a message."
    #Headers############################################
    $headers  'MIME-Version: 1.0' "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";
    // Additional headers
    $headers .= 'From: person<[email protected]>' "\r\n";
           
    mail($to$subject$message$headers); 
    not the best but it works.
    Without balance, there could only be chaos.
    Without chaos, there could be no balance.
    I live with karma. Eat with destiny. Dream of life without shackles....
    Yet. If life had no consequences, life could not exist, nor could it flourish.


    If at first you dont succeed.You're screwed.

    C++/Java NOOB.

    I aint a professional at PHP, but if i can help i will.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Location
    United States
    Posts
    157

    Re: Send Email by SMTP

    But I want to use the SMTP of my website.

  5. #5
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    Re: Send Email by SMTP

    You can either change the values in your php.ini file

    Code:
    [mail function]
    ; For Win32 only.
    SMTP = localhost ; for Win32 only
    smtp_port = 25
    sendmail_from= [email protected] ; for Win32 only
    or you can set the values dynamicaly if you don't have access to you php.ini file.

    PHP Code:
    ini_set("SMTP","localhost"); 
    The final method is to use sockets to connect manually to your SMTP server and send it that way, its the hardest is pointless as PHP already has built in support for sending emails, but if you want to use sockets them heres a link:

    http://uk.php.net/sockets

  6. #6
    Fanatic Member
    Join Date
    Oct 2004
    Posts
    751

    Re: Send Email by SMTP

    The send email that is built into PHP doesn't support SMTP auth, just do a google search for 'SMTP auth PHP'.
    My Projects: [ Instant Messagener Client/Server ] [ VBPictochat ]

    My Sites:
    [ Datanethost ]
    [ Helpdesk ]

    Remember if my post was helpful then Rate This Post.

  7. #7
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    Re: Send Email by SMTP

    Have you looked at:

    http://phpmailer.sourceforge.net/

    They say that it supports SMTP authentication but i haven't used it so im not sure if it fill definatly fit your needs.

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Location
    United States
    Posts
    157

    Re: Send Email by SMTP

    I want a simple php example to send an email by used SMTP.

  9. #9
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    Re: Send Email by SMTP

    PHP Code:
    <?php
    $to      
    '[email protected]';
    $subject 'the subject';
    $message 'hello';
    $headers 'From: [email][email protected][/email] . "\r\n" .
       '
    Reply-To: [email]webmaster@example.com[/email]' . "\r\n" .
       '
    X-MailerPHP/' . phpversion();
    ini_set("SMTP","smtp.yoursite.com");
    mail($to, $subject, $message, $headers);
    ?>
    Last edited by john tindell; Jan 9th, 2006 at 02:59 PM.

  10. #10
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Send Email by SMTP

    Irrelivant comments removed. Please don't Chit Chat in this forum.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

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



Click Here to Expand Forum to Full Width