Jump to content

Problem with mail not getting past my server


matt142857

Recommended Posts

Hi, I am having a problem with my Website mail.  Basically the mail was working fine yesterday but last night I  edited the PHP script slightly because for some reason the page that it was directed to had gone missing and was turning up an 404 error, which was just a newsuince as the email was still sent. So I just edited it so that it echo'ed a message saying thanks. but is seems today the mail is not getting to its destination. The PHP returns no errors and returns the success message fine but after saying its been sent it never appears.

I have tried different email addresses on different servers and that was no use and I have also changed the code back to how it was yesterday. and it still doesn't work.

I have also put the page up on one of my other sites which I know everything is set up properly and it works fine, making me think that it is a mail setup issue. but as I did not set up the mail at all and quite frankly don't really understand it, I don't know how it is meant to be set up as I just use google apps for sites that I set up.

 

So yeah I am trying to work out what could have gone wrong since yesterday but I don't really understand it,

below is the code as it as now and as it was yesterday:

<?php

$EmailFrom = "johnshale@hotmail.co.uk";
$EmailTo = "matthale.live@gmail.com";
$Subject = "Website enquiry";
$Name = Trim(stripslashes($_POST['Name'])); 
$Tel = Trim(stripslashes($_POST['Tel'])); 
$Email = Trim(stripslashes($_POST['Email'])); 
$Message = Trim(stripslashes($_POST['Message'])); 

// validation
$validationOK=true;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
  exit;
}

// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Tel: ";
$Body .= $Tel;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";

// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page 
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>

 

and the page is at www.sullyco.co.uk/contactengine.php as you can see the page is redirecting to a page that does not exist(contactthanks.php) indicating that the message was sent successfully. it is also the part I edited as a quick fix last night I just got it to echo a success message.

 

 

Thanks for any help on this, I have been trying to work it out all morning,

Matt

Link to comment
Share on other sites

Did your code ever have headers that it passed to the mail() construct? While it is possible for PHP to send an email without additional/custom headers, the default headers are not suited for most mail servers.

 

If you're on a linux server, you might be able to find mail that didn't get sent in a default or catch all account, depends ...

Link to comment
Share on other sites

It did have these basic headers:

 

$headers = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

 

Should I add more?

Cheers,

Matt

 

Those headers should work, there did appear to be present in the code snippet you pasted up top.  Make sure '$headers' is the last param in the mail() construct.

Link to comment
Share on other sites

Yeah its not in te code above but i did try that and is now in the code and reads as follows:

 

// send email 
$headers = 'From: webmaster@example.com' . "\r\n" . 'Reply-To: webmaster@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
$success = mail($EmailTo, $Subject, $Body, $headers);

 

But unfortunately it makes no difference.

Thanks,

Matt

Link to comment
Share on other sites

That come up with this, which I am not totaly sure what it means:

array(4) {
  ["type"]=>
  int(
  ["message"]=>
  string(21) "Undefined index:  Tel"
  ["file"]=>
  string(68) "/filer/1/en-www/109ALL767V4YN5CY/www.sullyco.co.uk/contactengine.php"
  ["line"]=>
  int(7)
}

 

Which I have left the code online if you go to http://www.sullyco.co.uk/contact.php and put some blurb in the text boxes(there is no email validation or anything at the moment.

 

Thanks,

Matt

Link to comment
Share on other sites

Okay, lets try this; create a new file and put the following code in it. Change the names and addresses as appropriate so that it uses real email addresses and names. Then run it in a browser. If this isn't working then there may be an issue with the server's SMTP settings.

 

<?php
$to  = 'test@test.com';
$toName = 'Test';
$from = 'me@me.com';
$fromName = 'Me';
$subject = 'Test Subject';

$message = '<b>This is a test message.</b>';

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'To: ' . $toName . ' <' . $to . '>' . "\r\n";
$headers .= 'From: ' . $fromName . ' <' . $from . '>' . "\r\n";

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

Link to comment
Share on other sites

I have just done that and unfortunately it also did not work, but again it worked fine on a test site, which as you say indicates a problem with the SMTP settings, unfortunately though I know very little about SMTP or mail settings of any sort.

 

 

Thanks again, I really appreciate the help you are giving,

Matt

Link to comment
Share on other sites

I do not know, I did not set it up, I just took it over. I know that the site is hosted by eclipse.net.uk which on there it says 'Email for sullyco.co.uk is configured for SMTP'

 

Apart from that I have no Idea, sorry, how do I find out?

 

Thanks,

Matt

 

Well, if you have a support contact, I would start there, and ask them for support. If you have shell access you could check the log dump on the server and see if anything is there. You could also try to find another mail server that you could make SMTP connections to.

 

Bottom line, without a valid MTA (Mail Transport Authority), PHP is not going to be able to transfer mail.

Link to comment
Share on other sites

Just to clarify, I am not the owner of the site or business I just re built and designed it not touching the original setup. Looking around the eclipse acount I cound this:

 

Email for domain sullyco.co.uk is configured for SMTP

The access account that your mail server is connected to is

na217282@adsl.eclipse.co.uk

The IP address that your mail server is running on is

82.152.45.250

If you wish to change these details, please click on the Modify button.

WARNING: If you are using your own mail server you will need to ensure that it is not misconfigured and operating as an open relay. If an open relay is running on your server then our mail servers may reject email from your server.

 

Suggesting that the company controls the server?

 

EDIT: in response to your next reply:

 

To be honest I am a little confused about what you just said there, sorry.

As it is a running business I am worried to go in and mess up there email system preventing any emails from being sent.

 

Thanks,

Matt

 

Link to comment
Share on other sites

Okay, well that's what it appears to be. So, basically, the most likely issue (especially if it's Exchange), is that the mail server is not allowing the web server as an authorized relay. The mail server admin needs to make the IP of this web server, an authorized relay server. He/She will not want to make it an 'open' relay and will want to require auth from the web server.

Link to comment
Share on other sites

OK so I should contact Eclipse and ask that they authorise the IP of the site then?

 

Thanks,

Matt

 

Yeah, whomever controls the mail server, needs to allow the IP addess of the web server as an authorized relay or sender. Now, most likely, they won't allow the web server to be an open relay. So they'll probably require the web server to authenticate before sending email.

 

If you get to that point; then in PHP, you should be able to make SMTP connections to the mail server, using the username and password they provide you. They may also give you a non-standard port to connect to, so be on the look out for that as well.

 

Feel free to PM or email me if you need further assistance, once you get to that point.

Link to comment
Share on other sites

Thanks again for the help, after sending a support ticket to Eclipse, before I have a reply it miraculously works again! I have also edited what I originally wanted and it still works fine, so I don't know if they did something before replying or what, but it works now so that's great.

Cheers,

Matt

Link to comment
Share on other sites

Thanks again for the help, after sending a support ticket to Eclipse, before I have a reply it miraculously works again! I have also edited what I originally wanted and it still works fine, so I don't know if they did something before replying or what, but it works now so that's great.

Cheers,

Matt

 

That's how it usually happens, you send a ticket, they fix it and usually don't respond. Congrats.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.