function will not send mail!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tobierre

    function will not send mail!

    Hi all,

    I've created the below function to automatically send me an alert in outlook
    when someone completes various forms on my website.

    The problem though is that mail reports that I have only 1 of the 3 required
    parameters defined!

    I have no idea where this is going wrong, because as far as I can tell I
    have defined all 3 parameters! Can anyone spot the problem?

    Regards
    Tobierre


    <?PHP
    function alert_outlook($ Type)
    {
    $Type = strtolower($Typ e);

    switch($Type)
    {
    case 'newsletter':
    $Subject = 'message subject one here';
    $Alert = "Hi,\n Just thought you would like to know that there has been
    another subscription to the newsletter!\n\n ";
    break;

    $Alert = wordwrap($Alert , 65);
    }

    //set headers etc
    $Recipient = "Auto Alerts<AutoAler ts@domain.com>" ;

    $Message = "\n\n{$Alert}\n \n\n";
    $Message .= 'Date: ' . date("l, js F Y") . "\n";
    $Message .= 'Time: ' . date("H:i:s") . "\n";
    $Message .= 'IP Address: ' . $_SERVER['REMOTE_ADDR'] . "\n\n";

    $Headers = "FROM: Auto Mailer<AutoMail er@Domain.com>\ r\n";

    mail("$Recipien t, $Subject, $Message, $Headers");

    //error check
    if(!mail("$Reci pient, $Subject, $Message, $Headers"))
    {
    return FALSE;
    }
    else
    {
    return TRUE;
    }
    }
    ?>


  • Philip Ronan

    #2
    Re: function will not send mail!

    "Tobierre" wrote:
    [color=blue]
    > I've created the below function to automatically send me an alert in outlook
    > when someone completes various forms on my website.
    >
    > The problem though is that mail reports that I have only 1 of the 3 required
    > parameters defined!
    >
    > I have no idea where this is going wrong, because as far as I can tell I
    > have defined all 3 parameters! Can anyone spot the problem?[/color]

    Try this (and see if you can spot the changes):

    <?php
    function alert_outlook($ Type)
    {
    $Type = strtolower($Typ e);

    switch($Type)
    {
    case 'newsletter':
    $Subject = 'message subject one here';
    $Alert = "Hi,\n Just thought you would like to know that there has been
    another subscription to the newsletter!\n\n ";
    break;
    default:
    $Subject = 'no subject';
    $Alert = '';
    }

    $Alert = wordwrap($Alert , 65);

    //set headers etc
    $Recipient = "Auto Alerts <AutoAlerts@dom ain.com>";

    $Message = "$Alert\n\n \n";
    $Message .= 'Date: ' . date("l, js F Y") . "\n";
    $Message .= 'Time: ' . date("H:i:s") . "\n";
    $Message .= 'IP Address: ' . $_SERVER['REMOTE_ADDR'] . "\n\n";

    $Headers = "From: Auto Mailer <AutoMailer@Dom ain.com>";

    mail("$Recipien t, $Subject, $Message, $Headers");

    //error check
    if(!mail("$Reci pient, $Subject, $Message, $Headers"))
    {
    return FALSE;
    }
    else
    {
    return TRUE;
    }
    }
    ?>

    --
    phil [dot] ronan @ virgin [dot] net


    Comment

    • Philip Ronan

      #3
      Re: function will not send mail!

      "Philip Ronan" wrote:
      [color=blue]
      > mail("$Recipien t, $Subject, $Message, $Headers");[/color]

      Oops, that should be

      mail($Recipient , $Subject, $Message, $Headers);

      --
      phil [dot] ronan @ virgin [dot] net


      Comment

      • Tobierre

        #4
        Re: function will not send mail!

        Hi phil,

        Thanks for that. Got rid of the PHP mail parser warning, but even with your
        suggestion it will still not send the e-mail! the error check returns
        false!!

        Got another suggestion? as I'm fresh out today

        Tobierre

        <invalid@invali d.invalid> wrote in message
        news:BFA8BBEB.3 B5FF%invalid@in valid.invalid.. .[color=blue]
        > "Tobierre" wrote:
        >[color=green]
        >> I've created the below function to automatically send me an alert in
        >> outlook
        >> when someone completes various forms on my website.
        >>
        >> The problem though is that mail reports that I have only 1 of the 3
        >> required
        >> parameters defined!
        >>
        >> I have no idea where this is going wrong, because as far as I can tell I
        >> have defined all 3 parameters! Can anyone spot the problem?[/color]
        >
        > Try this (and see if you can spot the changes):
        >
        > <?php
        > function alert_outlook($ Type)
        > {
        > $Type = strtolower($Typ e);
        >
        > switch($Type)
        > {
        > case 'newsletter':
        > $Subject = 'message subject one here';
        > $Alert = "Hi,\n Just thought you would like to know that there has been
        > another subscription to the newsletter!\n\n ";
        > break;
        > default:
        > $Subject = 'no subject';
        > $Alert = '';
        > }
        >
        > $Alert = wordwrap($Alert , 65);
        >
        > //set headers etc
        > $Recipient = "Auto Alerts <AutoAlerts@dom ain.com>";
        >
        > $Message = "$Alert\n\n \n";
        > $Message .= 'Date: ' . date("l, js F Y") . "\n";
        > $Message .= 'Time: ' . date("H:i:s") . "\n";
        > $Message .= 'IP Address: ' . $_SERVER['REMOTE_ADDR'] . "\n\n";
        >
        > $Headers = "From: Auto Mailer <AutoMailer@Dom ain.com>";
        >
        > mail("$Recipien t, $Subject, $Message, $Headers");
        >
        > //error check
        > if(!mail("$Reci pient, $Subject, $Message, $Headers"))
        > {
        > return FALSE;
        > }
        > else
        > {
        > return TRUE;
        > }
        > }
        > ?>
        >
        > --
        > phil [dot] ronan @ virgin [dot] net
        > http://vzone.virgin.net/phil.ronan/
        >[/color]


        Comment

        • Tobierre

          #5
          Re: function will not send mail!

          Hi Phil,

          Thank you, thank you

          Tobierre


          "Tobierre" <No-Reply@hotmail.c om> wrote in message
          news:11o61op5vu 31b34@corp.supe rnews.com...[color=blue]
          > Hi all,
          >
          > I've created the below function to automatically send me an alert in
          > outlook when someone completes various forms on my website.
          >
          > The problem though is that mail reports that I have only 1 of the 3
          > required parameters defined!
          >
          > I have no idea where this is going wrong, because as far as I can tell I
          > have defined all 3 parameters! Can anyone spot the problem?
          >
          > Regards
          > Tobierre
          >
          >
          > <?PHP
          > function alert_outlook($ Type)
          > {
          > $Type = strtolower($Typ e);
          >
          > switch($Type)
          > {
          > case 'newsletter':
          > $Subject = 'message subject one here';
          > $Alert = "Hi,\n Just thought you would like to know that there has been
          > another subscription to the newsletter!\n\n ";
          > break;
          >
          > $Alert = wordwrap($Alert , 65);
          > }
          >
          > //set headers etc
          > $Recipient = "Auto Alerts<AutoAler ts@domain.com>" ;
          >
          > $Message = "\n\n{$Alert}\n \n\n";
          > $Message .= 'Date: ' . date("l, js F Y") . "\n";
          > $Message .= 'Time: ' . date("H:i:s") . "\n";
          > $Message .= 'IP Address: ' . $_SERVER['REMOTE_ADDR'] . "\n\n";
          >
          > $Headers = "FROM: Auto Mailer<AutoMail er@Domain.com>\ r\n";
          >
          > mail("$Recipien t, $Subject, $Message, $Headers");
          >
          > //error check
          > if(!mail("$Reci pient, $Subject, $Message, $Headers"))
          > {
          > return FALSE;
          > }
          > else
          > {
          > return TRUE;
          > }
          > }
          > ?>
          >[/color]


          Comment

          • benny

            #6
            Re: function will not send mail!

            what you can do, do this way.
            I hope it will work.
            $is_sent = mail("$Recipien t, $Subject, $Message, $Headers");

            if ($is_sent === TRUE){
            echo "Sent successfully";
            }else{
            echo "Got problem in sending an email.";
            }


            Good luck.

            Comment

            • benny

              #7
              Re: function will not send mail!

              correction.

              $is_sent = mail($Recipient , $Subject, $Message, $Headers);


              if ($is_sent === TRUE){
              echo "Sent successfully";


              }else{


              echo "Got problem in sending an email.";


              }

              Comment

              Working...