Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #3233 > unrolled thread
| Started by | Integrated HR Solutions <ihrsolutions2011@gmail.com> |
|---|---|
| First post | 2011-09-29 06:18 -0700 |
| Last post | 2011-09-29 10:32 -0500 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.lang.php
problem sending email. Integrated HR Solutions <ihrsolutions2011@gmail.com> - 2011-09-29 06:18 -0700
Re: problem sending email. The Natural Philosopher <tnp@invalid.invalid> - 2011-09-29 16:07 +0100
Re: problem sending email. "Peter H. Coffin" <hellsop@ninehells.com> - 2011-09-29 10:32 -0500
| From | Integrated HR Solutions <ihrsolutions2011@gmail.com> |
|---|---|
| Date | 2011-09-29 06:18 -0700 |
| Subject | problem sending email. |
| Message-ID | <b64745c5-47d7-4322-8a1a-a4fc24bb85bf@g29g2000yqh.googlegroups.com> |
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?
[toc] | [next] | [standalone]
| From | The Natural Philosopher <tnp@invalid.invalid> |
|---|---|
| Date | 2011-09-29 16:07 +0100 |
| Message-ID | <j621iv$4jr$1@news.albasani.net> |
| In reply to | #3233 |
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@myisp.com' and the
mail will be junked as it has no valid sender.
Try something simple first like
mail("me@mymailaddess.com","TEST!!","From: me@mymailaddress.com",
"-fme@mymailaddress.com");
[toc] | [prev] | [next] | [standalone]
| From | "Peter H. Coffin" <hellsop@ninehells.com> |
|---|---|
| Date | 2011-09-29 10:32 -0500 |
| Message-ID | <slrnj893rp.hbg.hellsop@nibelheim.ninehells.com> |
| In reply to | #3233 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web