Jump to content

Form-to-email only sends email to hotmail...


Skeleten Neteleks

Recommended Posts

Hi, I am using the script below to send two html emails. One goes to my personal hotmail address (which is set in the PHP script), and the other goes to an email address which is typed into the form.

I have tested both methods and I have no problem receiving the email to my hotmail address.

I have tried addresses ending in @webnet2000.net and @tiscali.co.uk and @fsmail.net - no email received on any of them. Junk folders are empty and there are no known spam blockers in effect.

Can anyone tell me where I'm going wrong?

[code]<?php
function wpautop($pee, $br = 1) {
        $pee = $pee . "\n"; // just to make things a little easier, pad the end
        $pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee);
        // Space things out a little
        $pee = preg_replace('!(<(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)!', "\n$1", $pee);
        $pee = preg_replace('!(</(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])>)!', "$1\n\n", $pee);
        $pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines
        $pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates
        $pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "$1<p>\n", $pee); // make paragraphs, including one at the end
        $pee = preg_replace('|<p>\s*?</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace
        $pee = preg_replace('!<p>\s*(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|hr|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\s*</p>!', "$1", $pee); // don't pee all over a tag
        $pee = preg_replace("|<p>(<li.+?)</p>|", "$1", $pee); // problem with nested lists
        $pee = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $pee);
        $pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee);
        $pee = preg_replace('!<p>\s*(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|hr|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)!', "$1", $pee);
        $pee = preg_replace('!(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\s*</p>!', "$1", $pee);
        if ($br) $pee = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $pee);

        $pee = preg_replace('!(</?(?:table|thead|tfoot|caption|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\s*<br />!', "$1", $pee);
        $pee = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)!', '$1', $pee);
        $pee = preg_replace('!(<pre.*?>)(.*?)</pre>!ise', " stripslashes('$1') .  stripslashes(clean_pre('$2'))  . '</pre>' ", $pee);

        return stripslashes($pee);
}

$name = stripslashes($_POST['name']);
$date = $_POST['date'];
$email = $_POST['email'];
$message = wpautop($_POST['message']);

    //change this to your email.
    $to1 = "[email protected]";
    $from1 = "[email protected]";
    $subject1 = "$name's profile - $date";

    //change this to your email.
    $to2 = "$email";
    $from2 = "[email protected]";
    $subject2 = "$name's profile - $date";

    //begin of HTML message
    $message1 =
<<<EOF
<html>
<head></head>
<body>
Message: $message
</body>
</html>
EOF;

$message2 =
<<<EOF
<html>
<head></head>
<body>
Message: $message
</body>
</html>
EOF;
    //end of message
    $headers1  = "From: $from1\r\n";
    $headers1 .= "Content-type: text/html\r\n";

    $headers2  = "From: $from2\r\n";
    $headers2 .= "Content-type: text/html\r\n";

    //options to send to cc+bcc
    //$headers .= "Cc: [email][/email]";
    //$headers .= "Bcc: [email][/email]";
    header("Location: thankyou.html");

    // now lets send the email.
    mail($to1, $subject1, $message1, $headers1);
    mail($to2, $subject2, $message2, $headers2);
?>[/code]
Actually this issue has popped up again. I am seeking help with my hosting company (no longer doing it in-house) but preliminary diagnosis seems to indicate that the script is fine... and their servers don't have any restrictions... about who mail is sent to...

please help!!!
Just a long shot (i assume you have echoed the $mail / $to2 and found it ok)

Try to move your header("Location: thankyou.html"); below both mail calls, here is a suggestion:

[code]
<?php

$send_1 = mail($to1, $subject1, $message1, $headers1);
$send_2 = mail($to2, $subject2, $message2, $headers2);

if($send_1 && $send_2)
{
    header("Location: thankyou.html");
    exit();
}
else
{
    echo "Error:<br />";
    echo "1: ".$send_1."<br />";
    echo "2: ".$send_2."<br />";
}

?>
[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.