Lunarpages Web Hosting Forum

Author Topic: Mail function has stopped working  (Read 2111 times)

Offline Looney

  • Newbie
  • *
  • Posts: 5
Mail function has stopped working
« on: July 21, 2018, 03:36:50 AM »
I had a script that generated and sent an email. It was working fine a few months ago but has now stopped working. Now, even when I try a simple email script, it doesn't work. Has something changed?

The test script is
Code: [Select]
<?php
$to      
'myemail@gmail.com';
$subject 'the subject';
$message 'hello';
$headers 'From: webmaster@example.com' "\r\n" .
    
'Reply-To: webmaster@example.com' "\r\n" .
    
'X-Mailer: PHP/' phpversion();

mail($to$subject$message$headers);

?>


Offline MrPhil

  • Senior Moderator
  • Berserker Poster
  • *****
  • Posts: 6331
Re: Mail function has stopped working
« Reply #1 on: July 21, 2018, 05:17:25 AM »
The first thing I'd do is check whether your server's PHP version has been updated since mail was last known to have worked. Maybe there was something wrong in the build? When you say "it doesn't work", is there any error message? Does it look like the mail may have been sent, but is not being received at the other end? That could indicate some anti-spam measure on the receiving end is your problem. You might try sending to several different systems to see if only one is failing. Could your server be on a spam blacklist? If you get any bounce notices, they should say why mail was rejected (if it was sent at all). That's information that Support would need to try to clear your server off of a blacklist. How many emails are you sending out over what time period? LP does have caps on total mail activity for an account (could be multiple sites), so make sure you aren't exceeding that (e.g., 300 mails per hour). It looks like you are mailing outside of your own domain, so it doesn't sound like intradomain mails are being suppressed.

If none of these things shows an error on your side, and the failures continue, all you can do is open a Support ticket.
Visit My Site

E-mail Me
-= From the ashes shall rise a sooty tern =-

Offline Looney

  • Newbie
  • *
  • Posts: 5
Re: Mail function has stopped working
« Reply #2 on: July 21, 2018, 09:28:01 PM »
Thanks Mr Phil.

There's no error message. If I use an if (mail($to, $subject, $message, $headers)), etc it sends a message to say it's been successful.
I've tried sending to hotmail and gmail, checked spam, etc.

I'll send a support ticket. Just wanted to check it's not a known issue. Thanks

Offline Looney

  • Newbie
  • *
  • Posts: 5
Re: Mail function has stopped working
« Reply #3 on: July 29, 2018, 11:11:28 PM »
Support hasn't been too helpful. Apparently, the email is being treated as spam by the lunarpages mail filter. The reason given is that "_DOMAINSFrom and EnvelopeFrom 2nd level mail domains are different".

In the script I pasted, do I have to specify a particular "from" email address? I have tried setting it to one of the email addresses under my domain but that didn't work. Also, the script worked previously without giving a real address.

Any suggestions please?

Offline MrPhil

  • Senior Moderator
  • Berserker Poster
  • *****
  • Posts: 6331
Re: Mail function has stopped working
« Reply #4 on: July 30, 2018, 01:42:31 PM »
Have you told Support about the previous use of the script without a real address? Maybe it's remembering that, and you need to get Support to clear out the block. I have no idea what the message "_DOMAINSFrom and EnvelopeFrom 2nd level mail domains are different" is trying to say, other than that there seems to be a domain mismatch somewhere.
Visit My Site

E-mail Me
-= From the ashes shall rise a sooty tern =-

Offline Looney

  • Newbie
  • *
  • Posts: 5
Re: Mail function has stopped working
« Reply #5 on: July 31, 2018, 11:17:53 PM »
Nothing worse than an intermittent problem...

I managed to get the simple script to work. I'm not quite sure how. I changed the header information so that the sender email address matched my domain. That worked. But now even when I change it back to a random address it works.

Then I tried the real script, which attaches a PDF an emails it. It worked a few times but has now stopped.

When I use the Track Delivery program in the control panel, sometimes it says it succeeded in sending the email with the attachment (but I don't receive it). Sometimes it gives the error "SMTP error from remote mail server after MAIL FROM:<xxxx@agena.lunarpages.com> SIZE=1733: 452 Space shortage, please try later"

Any suggestions would be appreciated. Thanks

Offline MrPhil

  • Senior Moderator
  • Berserker Poster
  • *****
  • Posts: 6331
Re: Mail function has stopped working
« Reply #6 on: August 01, 2018, 04:11:09 AM »
Nothing worse than an intermittent problem...
Oh yeah...

Quote
...so that the sender email address matched my domain. That worked. But now even when I change it back to a random address it works.
I would stick with using a real address (matching your domain). What is the purpose of a "random" address? The field is there for a reason. Perhaps the mail system doesn't blacklist you for a fake address immediately, but after seeing several over a short period, it concludes you're spamming or otherwise doing something nasty.

Quote
When I use the Track Delivery program in the control panel, sometimes it says it succeeded in sending the email with the attachment (but I don't receive it). Sometimes it gives the error "SMTP error from remote mail server after MAIL FROM:<xxxx@agena.lunarpages.com> SIZE=1733: 452 Space shortage, please try later"
"Space shortage" sounds like a different problem than domain mismatches or other security issues. The recipient's mail system is apparently saying that it ran out of space to store what you sent. Is this a huge PDF you're attaching? Can small emails get through to this recipient? Do they even allow attachments, or restrict the type? Maybe this recipient is one of those problem people who leave all their emails on the mail system, rather than downloading it to their PC, and eventually run low on space. If so, it's your recipient's fault, not yours.

If it's a few recipients who have space problems, perhaps you should not be attaching (large) PDFs. You might want to consider just sending a link to the PDF (with some long, random key in the URL), and making the recipient pull in and download the PDF as a separate action. You may need to encrypt the PDF, if it contains sensitive information, and supply the key in another email.
Visit My Site

E-mail Me
-= From the ashes shall rise a sooty tern =-

Offline Looney

  • Newbie
  • *
  • Posts: 5
Re: Mail function has stopped working
« Reply #7 on: August 01, 2018, 04:27:54 AM »
Thanks MrPhil

The other thing I noticed, looking at the Delivery Tracking is that the Domain is mydomain.com but the Sender is user@agena.lunarpages.com. I'm thinking that this might be triggering the mail filter. Do you know if there is a way of setting the Sender to be the same as the Domain?

Offline MrPhil

  • Senior Moderator
  • Berserker Poster
  • *****
  • Posts: 6331
Re: Mail function has stopped working
« Reply #8 on: August 01, 2018, 09:46:38 AM »
I've heard of various applications such as SMF and osCommerce having trouble with PHP inserting a Sender or XPath of some sort using the server name instead of your actual domain, and this causing mismatches that were flagged as spam. I don't recall if anyone ever came up with a solid fix for this, but it may be time to search the eMail board here, and start Googling on PHP and mail and sender.
Visit My Site

E-mail Me
-= From the ashes shall rise a sooty tern =-