FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » problem sending email.
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
problem sending email. [message #175461] Thu, 29 September 2011 13:18 Go to next message
Integrated HR Solutio is currently offline  Integrated HR Solutio
Messages: 1
Registered: September 2011
Karma: 0
Junior Member
I have contact us page on my website here the php code for sending the
email:
<?php
header("refresh: 5; contact.html");
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-8" />
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<div class="mailform">
<?php
if(isset($_POST['Email'])) {

// CHANGE THE TWO LINES BELOW
$email_to = "info@mywebsite";

$email_subject = "Contact Form";

$fullname = $_POST['Name'];
$phone = $_POST['Phone'];
$altphone = $_POST['AltPhone'];
$email_from = $_POST['Email'];
$subject = $_POST['Subject'];
$message = $_POST['MoreInfo'];


$email_message = "Form details below.\n\n";

function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}

$email_message .= "Full Name: ".clean_string($fullname)."\n";
$email_message .= "Phone: ".clean_string($phone)."\n";
$email_message .= "Alternative Phone: ".clean_string($altphone)."\n";
$email_message .= "Subject: ".clean_string($subject)."\n";
$email_message .= "Message: ".clean_string($message)."\n";


// create email headers
$headers = 'From : '.$email_from."\r\n".
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>

<!-- place your own success html below -->

<p>����� ������</p>
<span> ����� ���� ��� ������</span>

<?php
}
die();
?>
</div>
</html>
___________________________________________________

somehow this doesn't work. It doesn't send the emails.

Where is the problem in this code?
Re: problem sending email. [message #175464 is a reply to message #175461] Thu, 29 September 2011 15:07 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
Integrated HR Solutions wrote:
> I have contact us page on my website here the php code for sending the
> email:
> <?php
> header("refresh: 5; contact.html");
> ?>
> <html>
> <head>
> <meta http-equiv="Content-Type" content="text/html;
> charset=ISO-8859-8" />
> <link rel="stylesheet" type="text/css" href="style.css">
> </head>
> <div class="mailform">
> <?php
> if(isset($_POST['Email'])) {
>
> // CHANGE THE TWO LINES BELOW
> $email_to = "info@mywebsite";
>
> $email_subject = "Contact Form";
>
> $fullname = $_POST['Name'];
> $phone = $_POST['Phone'];
> $altphone = $_POST['AltPhone'];
> $email_from = $_POST['Email'];
> $subject = $_POST['Subject'];
> $message = $_POST['MoreInfo'];
>
>
> $email_message = "Form details below.\n\n";
>
> function clean_string($string) {
> $bad = array("content-type","bcc:","to:","cc:","href");
> return str_replace($bad,"",$string);
> }
>
> $email_message .= "Full Name: ".clean_string($fullname)."\n";
> $email_message .= "Phone: ".clean_string($phone)."\n";
> $email_message .= "Alternative Phone: ".clean_string($altphone)."\n";
> $email_message .= "Subject: ".clean_string($subject)."\n";
> $email_message .= "Message: ".clean_string($message)."\n";
>
>
> // create email headers
> $headers = 'From : '.$email_from."\r\n".
> 'X-Mailer: PHP/' . phpversion();
> @mail($email_to, $email_subject, $email_message, $headers);
> ?>
>
> <!-- place your own success html below -->
>
> <p>����� ������</p>
> <span> ����� ���� ��� ������</span>
>
> <?php
> }
> die();
> ?>
> </div>
> </html>
> ___________________________________________________
>
> somehow this doesn't work. It doesn't send the emails.
>
> Where is the problem in this code?

Probably you need

mail($email, $subject, $message, $headers, "-f ".$return_path );

otherwise return path will be something like 'apache(at)myisp(dot)com' and the
mail will be junked as it has no valid sender.

Try something simple first like

mail("me(at)mymailaddess(dot)com","TEST!!","From: me(at)mymailaddress(dot)com",
"-fme(at)mymailaddress(dot)com");
Re: problem sending email. [message #175465 is a reply to message #175461] Thu, 29 September 2011 15:32 Go to previous message
Peter H. Coffin is currently offline  Peter H. Coffin
Messages: 245
Registered: September 2010
Karma: 0
Senior Member
On Thu, 29 Sep 2011 06:18:55 -0700 (PDT), Integrated HR Solutions wrote:
> // create email headers
> $headers = 'From : '.$email_from."\r\n".
> 'X-Mailer: PHP/' . phpversion();
> @mail($email_to, $email_subject, $email_message, $headers);
> ?>
[...]
> ___________________________________________________
>
> somehow this doesn't work. It doesn't send the emails.
>
> Where is the problem in this code?

See that @ at the front of the mail function? That's suppessing some
possible error messages. Take that off. You should be catching errors in
your code, not hiding them.

--
90. I will not design my Main Control Room so that every workstation is
facing away from the door.
--Peter Anspach's list of things to do as an Evil Overlord
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: discussing LeBron 8 PS
Next Topic: I want to read Wordpress blog
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 21:32:53 GMT 2024

Total time taken to generate the page: 0.02199 seconds