Results 1 to 4 of 4

Thread: If Mail Sent Echo ?? if not echo --.. Should be basic (i hope?) *rslvd*

  1. #1

    Thread Starter
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065

    If Mail Sent Echo ?? if not echo --.. Should be basic (i hope?) *rslvd*

    Hey ya,

    Am i right or wrong in thinking this should work?

    I want to tell the user that an email has been sent to their friend, IF it sends sucessfully, & if not, tell them the email failed..

    Is there a code error or?

    PHP Code:
        if(mail($to_name."<".$to_email.">"$subject$message$headers)){
            echo 
    "An email has been sent to ".$to_name." <a href=\"mailto:".$to_email."\">".$to_email."</a> telling him/her about ".$sitename."<BR>\n";
            echo 
    "Thank you for suggesting our website to your friend!<BR>\n<BR>\n";
            echo 
    "<a href=\"".$baseurl."\">Return To The Main Page</a>\n";
        }else{
            echo 
    "Failed to send the email to <a href=\"mailto:".$to_email."\">".$to_email."</a>\n";
        } 
    Last edited by wpearsall; Dec 5th, 2002 at 06:31 AM.
    Wayne

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    It should work, according to the manual:

    Code:
    mail() returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise.
    Try this to supress the errors and report on your own:

    Code:
    if(@mail(...)){
        echo "success!";
    }else{
        echo "Failed!";
    }
    What happens when you try that? Maybe you need to do:

    Code:
    if((@mail(...)) === true){
        echo "success!";
    }else{
        echo "Failed!";
    }
    I can't see why though.

    Also note that the function executing successfully does not ensure that the mail will make it. Wrong addresses, downed servers, etc could cause the mail to not make it.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3

    Thread Starter
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065
    oh, i meant to change the topic title in the nite,

    I solved it

    PHP Code:
    if(mail($to_name."<".$to_email.">"
    has to be:


    PHP Code:
    if(mail($to_email", 
    Woulda been nice to include the name in the headers, but No biggy

    Tnx anyhow
    Wayne

  4. #4
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    then send it in the headers. the $to is not the header. I believe it is

    $header = "To: name_here; FROM:: from_here";

    I am not sure if that works but it would look something like that.

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