mail command not working...

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
danf_1979
Forum Commoner
Posts: 72
Joined: Sun Feb 20, 2005 9:46 pm

mail command not working...

Post by danf_1979 »

Should this code work??? I got no mail in my yahoo account

Code: Select all

<?php
	$message = "hola qliao";
	$user_email = "danf_1979@yahoo.es";
	$subject = "prueba";
	$from = "yo mismo";
    mail($user_email, $subject, $message, "From: $from\nX-Mailer: PHP/" . phpversion());
	 echo "email sent";   
?>
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

try ::

Code: Select all

$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: MYSELFANDI <your@email.com>\r\n";
$headers .= "X-Sender: your@email.com\r\n";
$headers .= "X-Mailer: PHP\r\n";
$headers .= "X-Priority: 1\r\n";
$headers .= "Return-Path: your@email.com\r\n";

$subject = "My test mail";
$message ="<html><body>You got Mail</body></html>";
mail("your@email.com", $subject, $message, $headers);
danf_1979
Forum Commoner
Posts: 72
Joined: Sun Feb 20, 2005 9:46 pm

Post by danf_1979 »

It didnt work. How can I know if my web hosting company has mail function disabled or something?? I cant call know because is too late (night)
danf_1979
Forum Commoner
Posts: 72
Joined: Sun Feb 20, 2005 9:46 pm

Post by danf_1979 »

I saw a message in cpanel in my hosting provider. It says i should make sure SMTP is activated... does this make sense? I dont know how to configure SMTP to send mail in php
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

Meaning that you should login into your Cpanel and check if you have set your SMTP settings.

However if your hosting provider has any good service at all they wouldnt mind sending you a explaination on how to do that.

SMTP = Simple Mail Transfer Protocol ( Sending Mail )
POP3 = Post Office Protocol ( Receiving Mail )

To check if PHP Executed the command mail; [ example ]

Code: Select all

$email = "your@mail.com";
$ok = mail($email, $subject, $message, $headers);
if ($ok) {
echo "Mail succesfully Send to: ".$email;
} else {
echo "Error: Unable to send mail to: ".$email;
}
Post Reply