Email code only sends to certain email addresses

the mail() function

Moderators: macek, egami, gesf

mariopw
New php-forum User
New php-forum User
Posts: 5
Joined: Sat Jan 08, 2005 8:33 am
Location: Arizona, U.S.A.

Email code only sends to certain email addresses

Postby mariopw » Sat Jan 08, 2005 9:48 am

I need help. This code only sends an email to my certain email addresses.
Does anybody see anything wrong with the mail() code? Do I need to send anything preceeding the mail()? Is it assumed to be a spam and that is why is being block?
Tanks


Code: Select all

<?php //Script SendEmailNow.php

if (isset($_POST['submit'])) {     //Handle the Form
    $error_message = NULL;

    // Check for Your_Name -----------------

    if (strlen($_POST['Your_Name']) > 0) {
        $Your_Name = TRUE;
    } else {
        $Your_Name = FALSE;
        $error_message .= '<P>You forgot to enter your name!<BR>';
    }
    // Check for Your_Email -----------------

    if (strlen($_POST['Your_Email']) > 0) {
        $Your_Email = TRUE;
    } else {
        $Your_Email = FALSE;
        $error_message .= 'You forgot to enter your E-mail!<BR>';
    }
    // Check for Friend_Email_1 -----------------

    if (strlen($_POST['Friend_Email_1']) > 0) {
        $Friend_Email_1 = TRUE;
    } else {
        $Friend_Email_1 = FALSE;
        $error_message .= 'You forgot to enter your friends E-mail!<BR>';
    }

    // Check for Friend_Email_2 -----------------

    if (strlen($_POST['Friend_Email_2']) > 0) {
        $Friend_Email_2 = TRUE;
    } else {
        $Friend_Email_2 = FALSE;
    }
    // Check for Friend_Email_3 -----------------

    if (strlen($_POST['Friend_Email_3']) > 0) {
        $Friend_Email_3 = TRUE;
    } else {
        $Friend_Email_3 = FALSE;
    }

if ($Your_Name && $Your_Email && $Friend_Email_1) {  //All entries are OK!
    // Send an email.

    $body= "I recommend this website about the history of BPM. ";
    $subject = "Check this interesting website!";
    $headers = "From: {$_POST['Your_Email']}"."\r\nCc: {$_POST['Your_Email']}";
    $headers .= "\r\nBcc: myemail@domain.com";
    mail ($_POST['Friend_Email_1'], $subject, $body, $headers);
    if ($Friend_Email_2) {
       mail ($_POST['Friend_Email_2'], $subject, $body, $headers);
       }
    if ($Friend_Email_3) {
       mail ($_POST['Friend_Email_3'], $subject, $body, $headers);
       }
    $name = ucwords($_POST['Your_Name']);
    $name = urlencode($name);
    //$name = urlencode($_POST['Your_Name']);
    header ("Location: http://www.mywebsite.com/Submital.php?name=$name");
    exit();
   } else {
      $error_message .= '<P>Please try again.<P>';
   }
}

#Set page title and include the HTML header

$page_title = 'Email to a Friend.';
include ('./header.inc');

# ------------------------------ web-page -------------------------------------
// Print error message if there is one ----------------------------

if (isset($error_message)) {
    echo '<FONT FACE="verdana, arial, times" SIZE=2 COLOR="Red">', $error_message, '</FONT>';  //52 line
}
?>
<!- -------------------------[Request Info Form]------------------------------>
<TABLE ALIGN=Left WIDTH=100% BORDER=0 CELLPADDING=5 CELLSPACING=2 VSPACE=10>
<TR>
<TD ALIGN=Left><FONT COLOR="#000000">

<FORM ACTION="<?php echo $_SERVER['PHP_SELF']; ?>" METHOD="POST">
<INPUT TYPE=reset VALUE="Clear">&nbsp&nbsp
<FONT COLOR="#006699" FACE="arial, times" SIZE=3><B>To recommend this page to a friend, please fill in the form below:</B></FONT><P>
</TD>
</TR>
</TABLE>
<BR CLEAR=ALL>
<!- ----------------------------[Parameters]--------------------------------->
<INPUT SIZE=50 NAME="Your_Name" VALUE="<?php if (isset($_POST['Your_Name'])) echo $_POST['Your_Name']; ?>" >
Your Email :<INPUT SIZE=50 NAME="Your_Email" VALUE="<?php if (isset($_POST['Your_Email'])) echo $_POST['Your_Email']; ?>" >

1st - Friend's Email : <INPUT SIZE=50 NAME="Friend_Email_1" VALUE="<?php if (isset($_POST['Friend_Email_1'])) echo $_POST['Friend_Email_1']; ?>" >

2nd - Friend's Email: <INPUT SIZE=50 NAME="Friend_Email_2" VALUE="<?php if (isset($_POST['Friend_Email_2'])) echo $_POST['Friend_Email_2']; ?>" >

3rd - Friend's Email: <INPUT SIZE=50 NAME="Friend_Email_3" VALUE="<?php if (isset($_POST['Friend_Email_3'])) echo $_POST['Friend_Email_3']; ?>" >

Hit the SUBMIT MESSAGE button below, to send this information to your friends.<BR>
<INPUT TYPE="submit" NAME="submit" value="Submit message">
   </FORM>

<?php
?>[/quote][/quote]

User avatar
Alexej Kubarev
Site Admin
Site Admin
Posts: 2223
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län
Contact:

Postby Alexej Kubarev » Sat Jan 08, 2005 10:18 am

You should send this email only once, not several times..
What you can do is se the email address (the 1st parameter) to 1st_email + 2nd_email + 3d_email

So if one or both friends emails are empty: the email will be sent only to 1 person.. :)
The problem MIGHT be that you are sending them too fast... and therefore they are being blocked..

mariopw
New php-forum User
New php-forum User
Posts: 5
Joined: Sat Jan 08, 2005 8:33 am
Location: Arizona, U.S.A.

Postby mariopw » Sat Jan 08, 2005 4:02 pm

Thank you for your help.
mario
:grin:


Return to “PHP coding => Mail”

Who is online

Users browsing this forum: No registered users and 1 guest