Jump to content

Archived

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

Gruzin

Little help needed with php mail

Recommended Posts

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:

[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";
?>
[/code]

Share this post


Link to post
Share on other sites
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 [b]sendmail_from[/b] and [b]sendmail_path[/b] under the 'PHP Core' information.

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

Regards
Rich

Share this post


Link to post
Share on other sites
I've done it, here it is:

[color=red]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' [/color]

so whats the problem? thanks for your answer.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
[quote author=HuggieBear link=topic=105588.msg421849#msg421849 date=1156500482]
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
[/quote]

unfortunately no, if it won't take your time, can u tell me how to do that? thanks a lot.

Share this post


Link to post
Share on other sites
When you are using Windows, the following must be defined in your PHP.INI

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

; For Win32 only.
sendmail_from = your_emailid@your_provider.xx[/code]

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

Ronald  8)

Share this post


Link to post
Share on other sites
[quote author=ronverdonk link=topic=105588.msg421853#msg421853 date=1156500826]
When you are using Windows, the following must be defined in your PHP.INI

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

; For Win32 only.
sendmail_from = your_emailid@your_provider.xx[/code]

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

Ronald   8)
[/quote]

I don't think he's running a windows server.

Share this post


Link to post
Share on other sites
yes lessthanthree you are right, I'am not using windows server... just provider hosting.

Share this post


Link to post
Share on other sites

×

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.