Jump to content


Photo

Little help needed with php mail


  • Please log in to reply
7 replies to this topic

#1 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 25 August 2006 - 08:58 AM

hi guys I'am trying to write a simple php mail script, but it doesn't actually send the mail... I don't know, maybe someone will explain it to me. Thanks for your time. Here is the code:

<?php
$to = $_POST['mail'];
$subject = $_POST['sub'];
$message = $_POST['mes'];

$to = stripslashes($to);
$subject = stripslashes($subject);
$message = stripslashes($message);

mail($to, $subject, $message, "From: You<you@yoursite.com>\nX-Mailer: PHP/" . phpversion()) or die("Unable to send mail"); 
echo "Your email was sent successfuly";
?>

I don't need your script, I'll try to write it myself

#2 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 25 August 2006 - 09:41 AM

The mail() function within PHP relies on the PHP install knowing where sendmail is on your system at compile time.

If you use phpinfo() to get information about your install and then look for the values sendmail_from and sendmail_path under the 'PHP Core' information.

If these values are propgated then you're off to a good start.

Regards
Rich
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#3 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 25 August 2006 - 09:47 AM

I've done it, here it is:

sendmail_from me@localhost.com me@localhost.com
sendmail_path /bin/sendmail -t -i -f'postmaster@3d.caucasus.net' /bin/sendmail -t -i -f'CN_Webhosting'


so whats the problem? thanks for your answer.
I don't need your script, I'll try to write it myself

#4 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 25 August 2006 - 10:08 AM

Bad news is I've tried this code and it works fine, as expected.

So maybe your problem is with the PHP/Sendmail setup somewhere.  Do you know enough about sendmail to send yourself a test using sendmail to check that it's working?

Rich
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#5 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 25 August 2006 - 10:11 AM

Bad news is I've tried this code and it works fine, as expected.

So maybe your problem is with the PHP/Sendmail setup somewhere.  Do you know enough about sendmail to send yourself a test using sendmail to check that it's working?

Rich


unfortunately no, if it won't take your time, can u tell me how to do that? thanks a lot.
I don't need your script, I'll try to write it myself

#6 ronverdonk

ronverdonk
  • Members
  • PipPipPip
  • Advanced Member
  • 277 posts
  • LocationNetherlands

Posted 25 August 2006 - 10:13 AM

When you are using Windows, the following must be defined in your PHP.INI

; For Win32 only.
SMTP = mail.yourprovider.xx
smtp_port = 25

; For Win32 only.
sendmail_from = your_emailid@your_provider.xx

You SMTP must define your real mail provider and not localhost.xxx unless you run a mailserver yourself.

Ronald  8)
RTFM is an almost extinct art form, it should be subsidized.

#7 lessthanthree

lessthanthree
  • Members
  • PipPipPip
  • Advanced Member
  • 85 posts
  • LocationUK

Posted 25 August 2006 - 10:20 AM

When you are using Windows, the following must be defined in your PHP.INI

; For Win32 only.
SMTP = mail.yourprovider.xx
smtp_port = 25

; For Win32 only.
sendmail_from = your_emailid@your_provider.xx

You SMTP must define your real mail provider and not localhost.xxx unless you run a mailserver yourself.

Ronald   8)


I don't think he's running a windows server.
call me a safe bet, i'm betting i'm not

#8 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 25 August 2006 - 10:21 AM

yes lessthanthree you are right, I'am not using windows server... just provider hosting.
I don't need your script, I'll try to write it myself




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users