Results 1 to 9 of 9
  1. #1
    Join Date
    Jun 2008
    Posts
    7

    Unanswered: how to send mail using php script

    <?php
    $to = "yang2x_02@yahoo.com";
    $subject = "Hi!";
    $body = "Hi,\n\nHow are you?";
    $from="john@doe.com";
    if (mail($to, $subject, $body ,$from)) {
    echo("<p>Message successfully sent!</p>");
    } else {
    echo("<p>Message delivery failed...</p>");
    }
    ?>

    i'm trying to send some sample mail in my mail using the above code but it will never send in my email address..but i only run it in localhost but i'm connected in the internet. isn't ok? or do i need to make some configuration in php.ini? but i dnt knw wat to configure on it??can smebody help meh... tnxz

  2. #2
    Join Date
    Mar 2007
    Location
    010101010110100
    Posts
    803
    Quote Originally Posted by mahyang
    <?php
    $to = "yang2x_02@yahoo.com";
    $subject = "Hi!";
    $body = "Hi,\n\nHow are you?";
    $from="john@doe.com";
    if (mail($to, $subject, $body ,$from)) {
    echo("<p>Message successfully sent!</p>");
    } else {
    echo("<p>Message delivery failed...</p>");
    }
    ?>
    Your php code is fine.

    I'm going to make the assumption that you are on a windows box. This is the reason that you cannot send mail. If you are using a windows box, then yes, you will need to download a 3rd party SMTP server. If you are on a *nix box, then you should already have an MTA that will handle the mail for you.

  3. #3
    Join Date
    Jun 2008
    Posts
    7
    ahh k tnxz...

  4. #4
    Join Date
    Jul 2008
    Posts
    13
    The PHP mail() function is used to send emails from inside a script. syntax :- mail(to,subject,message,headers,parameters)

  5. #5
    Join Date
    Mar 2007
    Location
    010101010110100
    Posts
    803
    Shame on me.. I should have seen that. Maybe I was up late one night as I usually am.

  6. #6
    Join Date
    May 2008
    Posts
    10

    mail() spam problem

    Well I'd say 50% of the mail services that get my PhP generated emails send them directly to spam. I use mail() function to send my new users a varrification email when they sign-up, and it always get's caught in Yahoo's spam, and I'm pretty sure it gets caught in 70% of spam filters ever invented..

    Does anyone else have this problem? It makes me want to chuck the php mail function out the window! Although, it could be because I use 1and1 services and my mail subjects always say: "CGI Mail Service" or something like that..

    Am I right? ha

  7. #7
    Join Date
    Apr 2007
    Posts
    24
    use this code for simple email, it requires mail.php file to be include in your page. It does not able to send attachments.

    <?php
    include("Mail.php");
    /* mail setup recipients, subject etc */
    $recipients = "feedback@yourdot.com";
    $headers["From"] = "user@somewhere.com";
    $headers["To"] = "feedback@yourdot.com";
    $headers["Subject"] = "User feedback";
    $mailmsg = "Hello, This is a test.";
    /* SMTP server name, port, user/passwd */
    $smtpinfo["host"] = "smtp.mycorp.com";
    $smtpinfo["port"] = "25";
    $smtpinfo["auth"] = true;
    $smtpinfo["username"] = "smtpusername";
    $smtpinfo["password"] = "smtpPassword";
    /* Create the mail object using the Mail::factory method */
    $mail_object =& Mail::factory("smtp", $smtpinfo);
    /* Ok send mail */
    $mail_object->send($recipients, $headers, $mailmsg);
    ?>

  8. #8
    Join Date
    Sep 2008
    Posts
    2
    bool mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]] )

    Sends an email.

  9. #9
    Join Date
    Jul 2008
    Posts
    13
    Quote Originally Posted by mimizzee
    bool mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]] )

    Sends an email.

    That palpable for me. Please send me detail on these parameter. and let me know why we have use this parameter.

Posting Permissions

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