Thread: Php email help

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    156
    Rep Power
    13

    Php email help


    Hi

    I have a sign up form and want the sign up form to send a email to the user who has just signed up

    I have the following in my sign up form page

    PHP Code:
    <?php 
    $to 
    "$emailadd"
    $subject "Registration Information"
    $emailadd $_REQUEST['emailadd'];
    $password $_REQUEST['password'];
    $message $_REQUEST['message']; 
    $headers 
    "Email Address: $emailadd
    Password: 
    $password";
    $sent mail($to$subject$message$headers); 
    if(
    $sent) {print "Your mail was sent successfully"; } 
    else {print 
    "We encountered an error sending your mail"; } 
    ?>
    But am getting the following error

    We encountered an error sending your mail

    Any ideas where I am going wrong
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Hi,

    turn your error messages back on:
    PHP Code:
    error_reporting(-1); 
    This will tell you what's actually wrong.

    It seems you somehow confused the message with the email headers: That "Email Address: ... Password: " belongs to the message, not the headers. And you're missing a "From" header.

    It might be a good idea to use a mailer library like PHPMailer instead of fumbling with the low level "mail" function. Only do that if you really know what you're doing.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    156
    Rep Power
    13
    Hi

    I looked at the php mailer and to be honest that confused me as the download had so many pages that I was not sure what files to change and add to the coding etc
  6. #4
  7. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Just click on Wiki. It explains everything about the installation process and how to use PHPMailer.

IMN logo majestic logo threadwatch logo seochat tools logo