Welcome to Dream.In.Code
Become a PHP Expert!

Join 150,025 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,545 people online right now. Registration is fast and FREE... Join Now!




Sendmail problem. Please help.

 
Reply to this topicStart new topic

Sendmail problem. Please help.

frofi
2 Dec, 2006 - 03:01 PM
Post #1

New D.I.C Head
*

Joined: 2 Dec, 2006
Posts: 2


My Contributions
I am trying to make a PHP code using the sendmail function. I can make it work using the PHP built-in mail() function, but those emails arrive with “Sender” info, which is different from the “From” address and some spam filters stop it as spam. Therefore, I want to try the sendmail thing. I just don't know how it works. I've tried this:
CODE
$to = ($_POST['youremail']);
$from = 'donotreply@domain.com';
$subject = 'Do Not Reply';
$body = "Testing...”;
function send_mail($to, $from, $subject, $body) {
$path_to_sendmail = "/usr/sbin/sendmail";
$fp = popen("$path_to_sendmail -t", "w");
$num = fputs($fp, "To: $to\n");
$num += fputs($fp, "From: $from\n");
$num += fputs($fp, "Subject: $subject\n\n");
$num += fputs($fp, "$body");
pclose($fp);
if ($num>0) { return 1; } else { return 0; } }

Unfortunately it doesn't send anything. Is there something missing, or does something need adjusting?

This code works, but it does the “Sender” thing, which I don't want.
CODE
$to = ($_POST['youremail']);
$from = 'donotreply@domain.com';
$subject = 'Do Not reply';
$body = "Testing...”;
mail($to, $subject, $body, "From: $from\n");

User is offlineProfile CardPM
+Quote Post

Tuzoid
RE: Sendmail Problem. Please Help.
2 Dec, 2006 - 03:19 PM
Post #2

D.I.C Head
Group Icon

Joined: 20 Aug, 2006
Posts: 120



Thanked: 2 times
Dream Kudos: 50
My Contributions
I'm thinking you want headers!

http://us3.php.net/manual/en/function.mail.php

CODE

<?php
$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
   'Reply-To: webmaster@example.com' . "\r\n" .
   'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>

User is offlineProfile CardPM
+Quote Post

frofi
RE: Sendmail Problem. Please Help.
2 Dec, 2006 - 05:12 PM
Post #3

New D.I.C Head
*

Joined: 2 Dec, 2006
Posts: 2


My Contributions
Thanx for the answer. Unfortunately it still does the "Sender" thing. I would appreciate if someone showed me how to use the sendmail code I have posted. I wouldn't bother using these scripts, but my webhost's autoresponder service sends emails only where it chooses to. Which means it is useless and I have to use a code. I'm alright with other aspect of PHP, but I've never used mail functions before. I thing the one I am looking for is actually PEAR and it has to include this line:
CODE
$path_to_sendmail = "/usr/sbin/sendmail";

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 09:27PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month