Results 1 to 11 of 11

Thread: Errors with emailing script

  1. #1

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Errors with emailing script

    this script is not sending an email to my account. here is my code:

    PHP Code:
    <?php

    $confirmid 
    md5(date("Ymd"));
    $recipient "*******";
    $from "admin@*****.com";
    $subject "Account Activation";
    $message "Dear $membername: \n \n" .
        
    "Thank you for joining RapidFriends Social Networking! We are glad you joined. We need you to Activate your account by clicking the link located below. \n\n\n" .
        
    "<a href='confirm.php?id=$confirmid'>Confirm Account</a>\n\n" .
        
    "Note: If link above didnt work, go to http://www.rapidfriends.com/confirm.php, and copy this code into the text box: \n" 
        
    "Confirm Code: $confirmid";
    $headers "To: $membername <$memberemail>\n" 
        
    "From: RapidFriends Admin <$from>\n" 
        
    "MIME-Version: 1.0\n" 
        
    "Content-type: text/html; charset=iso-8859-1"
    mail('$recipient''$subject''$message''$headers');
    if (@
    mail('$recipient''$subject''$message''$headers')) { 
     echo(
    '<p>Mail sent successfully.</p>'); 
    } else { 
     echo(
    '<p>Mail could not be sent.</p>'); 


    ?>
    My usual boring signature: Something

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

    Re: Errors with emailing script

    Why are you putting variables in quotes:

    mail('$recipient', '$subject', '$message', '$headers');

    '$recipient' produces the string $recipient.

    Simply use the variable name.
    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.

  3. #3
    Frenzied Member I_Love_My_Vans's Avatar
    Join Date
    Jan 2005
    Location
    In the PHP compiler
    Posts
    1,275

    Re: Errors with emailing script

    Sometimes checking the rules for your STMP server helps, if Adams solution doesnt help.

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

    Re: Errors with emailing script

    don't do this:
    PHP Code:
    mail('$recipient''$subject''$message''$headers');
    if (@
    mail('$recipient''$subject''$message''$headers')) { 
     echo(
    '<p>Mail sent successfully.</p>'); 
    } else { 
     echo(
    '<p>Mail could not be sent.</p>'); 

    that will send the mail twice. that's not what you want. call mail() only once. either get rid of the if() statement, or get rid of the singular mail() call.

  5. #5
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Re: Errors with emailing script

    You can put variables in quotes e.g "my name is $name" but in this case its better without.

    Anyway I don't think thats whats stopping it. I think its the To field you specify in the header, why do you need this when you have already told it where to send to in the first argument mail(TO,...)
    Chris

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

    Re: Errors with emailing script

    SMTP headers are separated by \r\n, not \n.

  7. #7

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Errors with emailing script

    k thanks all for you help
    My usual boring signature: Something

  8. #8

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Errors with emailing script

    ok i now have this code, copied from php.net and it doesnt work...

    PHP Code:
    #SEND EMAIL
                        // multiple recipients
                        
    $to  "$email";
                        
                        
    // subject
                        
    $subject 'Confirm Your RapidFriends Account';
                        
                        
    // message
                        
    $message "
                        <html>
                        <head>
                          <title>Confirm Your RapidFriends Account</title>
                        </head>
                        <body>
                          <p>
                              Dear 
    $first, <br>
                              <br>
                              Thank you for signing up with RapidFriends Social Networking!
                            Before you can login, you must first confirm your account.<br>
                            <br>
                            <a href='http://www.rapidfriends.com/signup.php?step=3&confirm=
    $confirmcode'>Confirm Account</a><br>
                            <br>
                            If link doesnt apear above, copy and paste this URL into your browser:<br>
                            http://www.rapidfriends.com/signup.php?step=3&confirm=
    $confirmcode<br>
                            <br>
                            Thanks,<br>
                            RapidFriends Admin
                          </p>
                        </body>
                        </html>
                        "
    ;
                        
                        
    // To send HTML mail, the Content-type header must be set
                        
    $headers  'MIME-Version: 1.0' "\r\n";
                        
    $headers .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";
                        
                        
    // Additional headers
                        
    $headers .= "To: $first $last <$email>" "\r\n";
                        
    $headers .= 'From: RapidFriends Admin <[email protected]>' "\r\n";
                        
                        
    // Mail it
                        
    mail($to$subject$message$headers);
                        echo 
    "An email has been sent to $email. Please check it for your confirm link."
    i edited it for my needs
    My usual boring signature: Something

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

    Re: Errors with emailing script

    It doesn't work doesn't really tell us much. Are you not getting an email? Are you getting any errors?
    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.

  10. #10

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Errors with emailing script

    well me personaly am not getting the email. i have other people testing my code and they are getting the email.
    My usual boring signature: Something

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

    Re: Errors with emailing script

    The email is probably being flagged as spam and deleted. You need to ensure the domain part of the from address resolves to the same IP address as the server you are sending it from.
    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