PHP Mail not working

Status
Not open for further replies.

jpodirect13

New Member
Messages
5
Reaction score
0
Points
0
Hi, I tested to see if php mail is working for when I upload my site and after sending a text message I am still waiting to receive it is there a problem with the mail server or does it just not work full stop?

Thanks
 

stpvoice

Community Support Rep
Community Support
Messages
5,987
Reaction score
212
Points
63
Hello,

To what email address did you send it? E.g. was it to a Gmail, live etc?

Thanks.
 

jpodirect13

New Member
Messages
5
Reaction score
0
Points
0
Hi, it was to both gmail and live... sample script is

PHP:
<?php
// multiple recipients
$to  = 'james@******.co.uk' . ', '; // note the comma
$to .= '******@hotmail.co.uk';

// subject
$subject = 'Birthday Reminders for August';

// message
$message = '
<html>
<head>
  <title>Birthday Reminders for August</title>
</head>
<body>
  <p>Here are the birthdays upcoming in August!</p>
  <table>
    <tr>
      <th>Person</th><th>Day</th><th>Month</th><th>Year</th>
    </tr>
    <tr>
      <td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
    </tr>
    <tr>
      <td>Sally</td><td>17th</td><td>August</td><td>1973</td>
    </tr>
  </table>
</body>
</html>
';

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: James ***** <james@******.co.uk>' . "\r\n";
$headers .= 'From: JPO Legal Team <info@******.co.uk>' . "\r\n";

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

thank
 

Anna

I am just me
Staff member
Messages
11,755
Reaction score
583
Points
113
You'll need to have text/plain as content-type for it to work, mail server silently eats the mail otherwise.
 

stpvoice

Community Support Rep
Community Support
Messages
5,987
Reaction score
212
Points
63
Hello,

I've spoken to one of our admins. Apparently, php mail only works if the type is set to text/plain. Also, there are known issues with sending to both gmail and windows live, as the free servers are often blacklisted due to past abuse. I know for a fact that in some cases, windows live won't even display a message sent from free. It doesn't even go into spam.
 

jpodirect13

New Member
Messages
5
Reaction score
0
Points
0
Ok I have changed the content type as advised, still getting problems though, included a little error catch in the code to see if it is actually working before being sent out...

PHP:
<?php
// multiple recipients
$to  = 'james@********' . ', '; // note the comma
$to .= '********@hotmail.co.uk';

// subject
$subject = 'Testing Email for site';

// message
$message = '
Test Email Message
';

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/plain; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: James *********l <james@********.co.uk>' . "\r\n";
$headers .= 'From: JPO Legal Team <info@********t.co.uk>' . "\r\n";

// Mail it
if (mail($to,$subject,$message,$headers) ) {
	   echo "email sent";
	} else {
	   echo "email couldn't be sent";
};
?>

Is there something wrong in this code or am I doing things correctly?

Thanks
 

Anna

I am just me
Staff member
Messages
11,755
Reaction score
583
Points
113
The code works fine, I just copied it onto my test acct on the same server as you're on, and it sent nicely to gmail and my personal domain.

Most likely the emails would come to either spam bin, or in worst case silently be dropped by the recipients mail provider due to our servers being marked as sending spam (past abuse does cause a problem with some providers), if they aren't located in the inbox.
 

taha116

Member
Messages
505
Reaction score
0
Points
16
I have a similar problem, but the thing is I dont know much about php myself. Im using opencart and I cant seem to have any activation emails mailed out automatically. anything you guys can think of thatll help?
 
Status
Not open for further replies.
Top