Question about mail()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
matthiasone
Forum Contributor
Posts: 117
Joined: Mon Jul 22, 2002 12:14 pm
Location: Texas, USA
Contact:

Question about mail()

Post by matthiasone »

Posted: Thu Jul 25, 2002 1:20 pm Post subject: use the mail() function

--------------------------------------------------------------------------------

I am have touble sending mail using the mail function in PHP. I beleive the path is sent right for sendmail. when I run the function, I get a false returned from the function. Is there a way to determine why it returned a false?

MatthiasOne
User avatar
llimllib
Moderator
Posts: 466
Joined: Mon Jul 01, 2002 2:19 pm
Location: Baltimore, MD

Post by llimllib »

Well, I'm gonna come in ahead of Twinglet, and say that it's not polite to cross-post. This question really belongs here, not in Databases.

That said, try and send a piece of mail from the command line; make sure exactly what you type there goes into php.ini. After that...well, that's all I can come up with right now.
matthiasone
Forum Contributor
Posts: 117
Joined: Mon Jul 22, 2002 12:14 pm
Location: Texas, USA
Contact:

Post by matthiasone »

I know..........I posted before I realized what forum I was in...........sorry
User avatar
llimllib
Moderator
Posts: 466
Joined: Mon Jul 01, 2002 2:19 pm
Location: Baltimore, MD

Post by llimllib »

i figured that was the case, and it's not a problem, just letting you know. Don't worry about it.

Did you try to send a piece of mail from the command line?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Well, I'm gonna come in ahead of Twinglet, and say that it's not polite to cross-post.
:lol: Someone has to keep everybody in line.

matthiasone - which operating system are you running?

Mac
matthiasone
Forum Contributor
Posts: 117
Joined: Mon Jul 22, 2002 12:14 pm
Location: Texas, USA
Contact:

Post by matthiasone »

Unix (FreeBBS) on the web server
User avatar
llimllib
Moderator
Posts: 466
Joined: Mon Jul 01, 2002 2:19 pm
Location: Baltimore, MD

Post by llimllib »

do you have shell access?
matthiasone
Forum Contributor
Posts: 117
Joined: Mon Jul 22, 2002 12:14 pm
Location: Texas, USA
Contact:

Post by matthiasone »

No, just ftp access
User avatar
llimllib
Moderator
Posts: 466
Joined: Mon Jul 01, 2002 2:19 pm
Location: Baltimore, MD

Post by llimllib »

could you perhaps email an admin and ask him to check your sendmail location? Do you definitely have sendmail access?
Otherwise, if you have an SMTP server anywhere, you could use the PEAR::smtp class to send mail. You can make it appear to be from you no matter what smtp server it goes through, and it's probably more portable anyway.
matthiasone
Forum Contributor
Posts: 117
Joined: Mon Jul 22, 2002 12:14 pm
Location: Texas, USA
Contact:

Post by matthiasone »

Well we (the admin and I) have already verified the send mail location, though it does contain an "-t -i" after the path that we are not sure what that means. I think I have sendmail access.......at least that is what I was told by the admin.

How does that PEAR::SMTP work..........we have a mail server (Exchange) on a different server
User avatar
llimllib
Moderator
Posts: 466
Joined: Mon Jul 01, 2002 2:19 pm
Location: Baltimore, MD

Post by llimllib »

Ok, there's no manual at the normal pear site, but there is a manual for pear::smtp here. The code sample they give is:

Code: Select all

<?php
include('Mail.php');

$recipients = 'joe@example.com';

$headers&#1111;'From']    = 'richard@phpguru.org';
$headers&#1111;'To']      = 'joe@example.com';
$headers&#1111;'Subject'] = 'Test message';
    
$body = 'Test message';

$params&#1111;'host'] = 'mail.example.com';
    
// Create the mail object using the Mail::factory method
$mail_object =& Mail::factory('smtp', $params);

$mail_object->send($recipients, $headers, $body);
?>
The classes you need are: pear/Mail.php; pear/mail/smtp.php; pear/net/smtp.php; pear/net/socket.php. If you don't have any of them, go to cvs.php.net and look in the pear directory to download them, or I'll email them to you if you want. You can set authorization in the $params, look at the manual page.
matthiasone
Forum Contributor
Posts: 117
Joined: Mon Jul 22, 2002 12:14 pm
Location: Texas, USA
Contact:

Post by matthiasone »

go ahead and mail them to me........to make sure I get the right ones. I looked at the socket.php and it called pear.php..........do I need that one too?

Matt
User avatar
llimllib
Moderator
Posts: 466
Joined: Mon Jul 01, 2002 2:19 pm
Location: Baltimore, MD

Post by llimllib »

if you have any pear installed (i assumed you did) then pear.php should be in the pear/ directory.
Also, if i'm gonna email you, I'll need an address.
matthiasone
Forum Contributor
Posts: 117
Joined: Mon Jul 22, 2002 12:14 pm
Location: Texas, USA
Contact:

Post by matthiasone »

I don't think I have any pear install if I do I don't know about it

mphillips@lufkin.org


Matt
Post Reply