Jump to content

advise


skippy111

Recommended Posts

Hi Guys,

 

I have used a snippet of code all over the web on all my websites.  I signed up last night with cyberultra hosting.  I have used them in the past and the php code I have used always worked there but now it does not.

 

I have a business website and I like to see when its visited via being sent an email which includes ip address of the visitor.  I have always used a php file to do this via  loading the php file  with iframe flash  etc.    I am being told they updated security and being told about  From headers  and they dont know why it wont work.  It has worked all over but will not work now.  Can anyone offer a potential solution ?    I also have a form that sends mail but is not sending as it always has.

 

I have used this code with success

 

<?php

 

 

 

$email = "myemail@yahoo.com";

 

$continue = "http://www.yahoo.com";

 

$subject = "Someone with this IP viewed the site";

$message = "From: $name\nEmail address: $formemail\n\n$comments\n\n-\nmy site 2008  \n-------";

$headers = "From: " . $formemail . "\n" . "Return-Path: " . $formemail . "\n" . "Reply-To: " . $formemail . "\n". $_SERVER['REMOTE_ADDR']."\n";

 

mail($email,$subject,$message,$headers);

 

 

?>

 

this has worked on every host I ever used  but now it will not work at my current host.  They are not providing much help at all.  What changes can be made to comply with the  from header suggestion they claim to be the problem ?

 

Thanks

 

Link to comment
Share on other sites

Yeah, sometimes places will make you use a FROM address that is recognized by them.

 

Set up an email account like formemail@yourdomain.com and set the FROM header to that. Or just leave out the FROM header, and it will come from the PHP process.

 

mail($email,$subject,$message);

Link to comment
Share on other sites

its still not sending mail.  I just dont understand why.  Ive tried everything

 

here is my contact form that I have never had a problem with before and its not working either.  It acts like it is but no mail sent.

 

 

<?php

 

 

 

$valid_ref1="http://www.mysite.com/contact.html";

$valid_ref2="http://www.mysite.com/contact.html";

$replyemail="myemail@yahoo.com";

 

 

//clean input in case of header injection attempts!

function clean_input_4email($value, $check_all_patterns = true)

{

$patterns[0] = '/content-type:/';

$patterns[1] = '/to:/';

$patterns[2] = '/cc:/';

$patterns[3] = '/bcc:/';

if ($check_all_patterns)

{

  $patterns[4] = '/\r/';

  $patterns[5] = '/\n/';

  $patterns[6] = '/%0a/';

  $patterns[7] = '/%0d/';

}

//NOTE: can use str_ireplace as this is case insensitive but only available on PHP version 5.0.

return preg_replace($patterns, "", strtolower($value));

}

 

$name = clean_input_4email($_POST["name"]);

$email = clean_input_4email($_POST["email"]);

$thesubject = clean_input_4email($_POST["thesubject"]);

$themessage = clean_input_4email($_POST["themessage"], false);

$Phone = clean_input_4email($_POST["Phone"]);

$error_msg='ERROR - not sent. Try again.';

 

$success_sent_msg='<p align="center"><strong> </strong></p>

                  <p align="center"><strong>Your message has been successfully sent to us<br>

                  </strong> and we will reply as soon as possible.</p>

                  <p align="center">A copy of your message has been sent to you.</p>

                  <p align="center">Thank you for contacting us.</p>';

 

 

 

 

 

 

 

 

$replymessage = "Hi $name

 

Thank you for your email.

 

We will  reply to you shortly.

 

Please DO NOT reply to this email.

 

Below is a copy of the message you submitted:

--------------------------------------------------

Name: $name

Email: $email

Phone: $Phone

Subject: $thesubject

Message: $themessage

--------------------------------------------------

 

Thank you";

 

// email variable not set - load $valid_ref1 page

if (!isset($_POST['email']))

{

echo "<script language=\"JavaScript\"><!--\n ";

echo "top.location.href = \"$valid_ref1\"; \n// --></script>";

exit;

}

 

$ref_page=$_SERVER["HTTP_REFERER"];

$valid_referrer=0;

if($ref_page==$valid_ref1) $valid_referrer=1;

elseif($ref_page==$valid_ref2) $valid_referrer=1;

if(!$valid_referrer)

{

echo "<script language=\"JavaScript\"><!--\n alert(\"$error_msg\");\n";

echo "top.location.href = \"$valid_ref1\"; \n// --></script>";

exit;

}

$themessage = "Name: $name\nEmail: $email\nPhone: $Phone\nMessage: $themessage";

mail("$replyemail",

    "$thesubject",

    "$themessage",

    "From: $email\nReply-To: $email");

mail("$email",

    "Receipt: $thesubject",

    "$replymessage",

    "From: $replyemail\nReply-To: $replyemail");

echo $success_sent_msg;

echo"<div align=\"center\"><a href=\"index.html\">Home</a></div>"

."";

?>

 

Link to comment
Share on other sites

but this dont work either  and its using my email at the same domain 

 

$email = "myemail@yahoo.com";

 

$continue = "http://www.yahoo.com";

 

$subject = "Someone with this IP viewed the site";

$message = "From: $name\nEmail address: $formemail\n\n$comments\n\n-\nmy site 2008  \n-------";

$headers = "From: myname@mydomain.com";

 

mail($email,$subject,$message,$headers);

 

 

everything that usualy works is failing 

 

so what is a sure fire way just for testing purposes to get this host im using to send me a test mail using php ?  Nothing seems to work

Link to comment
Share on other sites

That is something you need to work out with your host then. They seem to be a bit over protective if that script won't even send.

 

One last check. In a new, clean PHP file, put the code:

 

<?php
  $to = "myemail@yahoo.com"; //Set to your Yahoo email address
  $from = "myname@mydomain.com"; //Set to a REAL email address from your domain

  $subject = "Test email";
  $message = "Email body";
  $headers = "From: $from";

  mail($email,$subject,$message,$headers)
    or die("Couldn't send email");
  print "Done";
?>

 

Also, out of curiosity, who is your hosting company?

Link to comment
Share on other sites

Ask them to tell you exactly what it needs to be, and then have them test it.

 

Do you have a error log?  If so, the errors should be in there for why it's not sending.

 

 

so what is a sure fire way just for testing purposes to get this host im using to send me a test mail using php ?  Nothing seems to work

Link to comment
Share on other sites

"Couldn't send email "    unreal  edited to my yahoo  and to my domain email  just as you asked

 

 

the host is cyberultra      I have used them and all of the above scripts  as recently as last year. Never a problem.

 

 

I have talked to 6 different people today and still no solution

Link to comment
Share on other sites

from a level 2 tech 

 

Hello,

 

I believe the problem here lies in the mail aspect of your script. The

server had a backed up queue full of mail to yahoo and your messages

were not able to get through. I have cleared these emails and now the

server is able to send mail to your yahoo account again. Please let us

know if you need any further assistance.

 

still has not fixed the problem

Link to comment
Share on other sites

I was able to get the scripts up and running using a different email.  I was also able to get the scripts to send to yahoo but not the address I wanted it to send to. Very strange. The yahoo mail has an underscore  my_mail@yahoo.com  no matter what I try it will not send to that mail.  When I try to send to a yahoo name with no underscore it seems to work fine. 

 

Any ideas what might be going on here ?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.