View Full Version : Mail
02-25-2006, 09:57 PM
I'm trying to figure out how to use the mail command in PHP, but it won't work for some reason. I have a couple general ideas as to why it doesn't work, but I don't know if any of them are the correct reason. Here are my ideas:
-the mail function doesn't work in PHP 4.1.03 (i think is the version)
-the mail function doesn't work unless run from a server, as in, when testing it on my home computer for developmental purposes, it won't work
-smtp.yahoo.com is malfunctioning
-i'm writing the script wrong
A couple of those could all be the reason, whereas a couple could be completely dumb ideas as to why it doesnt work. But could somebody please help clear this up for me?
Thanks in advance.
-the mail function doesn't work in PHP 4.1.03 (i think is the version)Should do, as far as I remember.
-the mail function doesn't work unless run from a server, as in, when testing it on my home computer for developmental purposes, it won't workYou're using a remote server (smtp.yahoo.com).
-smtp.yahoo.com is malfunctioningCan you send email? If so, it's not malfunctioning.
Which only leaves:
-i'm writing the script wrong:)
02-25-2006, 10:51 PM
I thought i correctly copied the Mail script right out of the book to see if it'd work.
Could it be that the sendmail_from part of the [Mail] portion is entered incorrectly?
the code looks like this i beleive:
;sendmail_from = email@example.com
That semi-colon before the sendmail thing, could that affect the situation?
If not, then I'm all out of options other than I'm writing it wrong :p .
Well, I guess it just could, being as it causes PHP to completely ignore anything after the semicolon. I guess that could cause a problem, in a few rare cases... :D
02-25-2006, 11:24 PM
Allright, well i'll remove the semicolon there, and then i'll rewrite my script :) .
02-26-2006, 12:08 AM
One last thing. I'm new to PHP, just started learning it this week. But can you help me find whats wrong with my code?
$to = "firstname.lastname@example.org";
$subj = "Test";
$message = "This is a mail service test message.";
$mailsend = mail($to,$subj,$message);
echo "Mail not sent.";
echo "Mail sent.";
That is my entire code, and it's supposed to execute the mail function immediately when the page loads, or so I've understood.
But that's my code, is something wrong with it that would cause me to get this outcome: Mail not sent.
Every time i try to run the script?
it's supposed to execute the mail function immediately when the page loads, or so I've understood.Not quite; it should execute the mail() function when the page is requested. PHP, as a server-side language, doesn't know or care what happens after the page has been sent from the server.
Your firewall could be blocking PHP from connecting to the SMTP server. Try allowing it and seeing what happens. If that fails, write your own simple mail() function using fsockopen (http://www.php.net/fsockopen)() and see where it dies.
02-26-2006, 03:36 PM
So, the mail() function won't execute when my page loads? Do i have to link to the page or something?
So, the mail() function won't execute when my page loads?No, it executes before your page loads (for the client, that is) :)
02-26-2006, 08:29 PM
So now I just have to make sure I'm coding it correctly and I'm all set.
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.