Email not getting through

the mail() function

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 1
Joined: Mon Jan 23, 2012 11:56 am

Email not getting through

Postby nick2price » Mon Jan 23, 2012 12:02 pm

Hey, I never receive email with my php code, and my host is saying that all services are up and mail is enabled. However, I am sure it is a host problem, I cannot see what else it can be. Just want to clear things up quickly though. In my root folder, I create a php file called test. Inside this file is the basic code

Code: Select all

$ADDR = "";
if (mail($ADDR,"Testing","This is a test")) {
echo "Mail function succeeded<br />";
} else {
echo "Mail function FAILED<br />";

If I then navigate to the url, will the php code automatically be executed? And could someone please confirm that the code is correct. When I navigate to the url, I get returned the succeeded message. So it appears it works, but the mail never gets delivered. I have tried different email addresses all with different providers.

Could anyone shed some light on what my issue may be?

Many thanks

User avatar
New php-forum User
New php-forum User
Posts: 137
Joined: Wed Aug 31, 2011 3:55 am
Location: USA

Re: Email not getting through

Postby bigjoe11a » Sun Jan 29, 2012 1:31 pm

1st check your junk folder. Make sure that your filtered list includes the domain name from and to the email that your sending.

or if that doesn't work. Try using this. Just change the email names to the ones you want to use. Your sample above doesn't include any header information

Code: Select all

// recipients email address
$to  = ''; // note the comma

// subject
$subject = 'Subject of the message';

// message
$message = 'Type in the body of your message here';

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: Mary <>' . "\r\n";
$headers .= 'From: My Name <>' . "\r\n";
$headers .= 'Cc:' . "\r\n";
$headers .= 'Bcc:' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);

Return to “PHP coding => Mail”

Who is online

Users browsing this forum: No registered users and 4 guests