Results 1 to 11 of 11

Thread: php mail

  1. #1

    Thread Starter
    Lively Member sridharao's Avatar
    Join Date
    Feb 2007
    Posts
    106

    php mail

    While searching the net I found a rather simple lines of code for sending email.
    PHP Code:
    $to "[email protected]";
    $subject "site feedback";
    $message stripslashes(trim($_POST['mssg']));
    $from "[email protected]";
    $headers "From: ".$_POST['user'];
    mail($to,$subject,$message,$headers); 
    I know, this is not ALL, there has to be more to it. I have not specified mail server and stuff like that. How can I set it up on my site?

    I am running wampserver and email page is in localhost. Can I send email from my desktop? I found 2 more lines of code to be appended before mail(), these are:
    ini_set("SMTP","smtp.example.com" );
    ini_set('sendmail_from', '[email protected]');
    It refuses to work. here is the error message:
    Warning: mail() [function.mail]: SMTP server response: 501 5.7.1 <[email protected]>... Sender refused by the DNSBL xbl.spamhaus.org
    Last edited by sridharao; Jul 15th, 2009 at 11:01 AM.
    Save trees, avoid plastics, say no to zoo, go veg, recycle as much, live holistic

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: php mail

    using mail() assumes that you have a mail server to use. you can set it up in the INI file, but most SMTP servers require authentication and the mail() function lacks the ability to authenticate you to outside servers (like hotmail, gmail, or your ISP's mail server). instead, you could use the PHPMailer class to send mail.

  3. #3

    Thread Starter
    Lively Member sridharao's Avatar
    Join Date
    Feb 2007
    Posts
    106

    Re: php mail

    I checked out PHPmailer. I am stuck right at the beginning. The documentation states;
    Copy class.phpmailer.php into your php.ini include_path. If you are using the SMTP mailer then place class.smtp.php in your path as well.
    On a server where my site is hosted, how can I do that?
    The mail server available to me is mail.mydomain.com
    How do I proceed from here?

    further additions:
    These are the folders installed in wamp folder; alias, appa, bin, lang, logs, scripts, tmp, www
    "Copy class.phpmailer.php into your php.ini include_path." Where is that?
    I located php.ini at C:\wamp\bin\php\php5.2.9-1. In this file is an entry ";include_path = ";include_path = ".;c:\php\includes"" but there is no such folder in C: drive. So, where should I place class.phpmailer.php

    Also noted that there is a folder named pear inside php5.2.9-1 folder. How can I use pear mail?
    Last edited by sridharao; Jul 21st, 2009 at 09:04 AM.
    Save trees, avoid plastics, say no to zoo, go veg, recycle as much, live holistic

  4. #4

    Thread Starter
    Lively Member sridharao's Avatar
    Join Date
    Feb 2007
    Posts
    106

    Re: php mail

    I am still waiting for reply

  5. #5
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: php mail


  6. #6

    Thread Starter
    Lively Member sridharao's Avatar
    Join Date
    Feb 2007
    Posts
    106

    Re: php mail

    Ok,

    The problem is solved, Thanks for the link. In fact, the documentation of phpmailer itself was clear enough. I had to struggle a bit in placing the class.phpmailer.php in the require statement. A little search and got the answer.

    All is well, except that the mails sent in this fashion is considered spam and gets delivered straight into spam or junk folder. Why could this be so?
    Last edited by sridharao; Jul 22nd, 2009 at 08:51 PM.
    Save trees, avoid plastics, say no to zoo, go veg, recycle as much, live holistic

  7. #7
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: php mail

    probably has to do with your mail headers, the content of your mail, or your domain's MX records. I really can't provide any help to fix your problem though.

  8. #8

    Thread Starter
    Lively Member sridharao's Avatar
    Join Date
    Feb 2007
    Posts
    106

    Resolved Re: php mail

    It's working, as you said it had something to do with MX records. Really, PHPmailer is indeed a boon to webmasters.

  9. #9
    Addicted Member
    Join Date
    Mar 2009
    Posts
    156

    Re: php mail

    I'm sending a html page to an email address through a godaddy server and when it is received by the recipient, it shows it's from that server as one would expect.

    What can I do with '$headers' or others that would allow people to answer / reply to my own email address because otherwise the person repling gets a failure message from godaddys server?

    I know I can put in a weblink but is there an easy - more common option for users.

  10. #10
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: php mail

    Sounds like you're not setting the From header correctly.

    Additionally, you can set Reply-to, but this is usually only used if the reply address is specifically different from the originating address. In either case From should be set.

  11. #11
    Addicted Member
    Join Date
    Mar 2009
    Posts
    156

    Re: php mail

    Reply-to works great thanks penagate

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