php mail() on free webspace
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Plusnet Community
- :
- Forum
- :
- Help with my Plusnet services
- :
- Everything else
- :
- Re: php mail() on free webspace
php mail() on free webspace
15-11-2016 7:20 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
I using the free webspace i have with by broadband to develop a website.
I'm finding that mail() does not always send.
I'm doing everything right, but sometimes it just doesnt send emails, Is there a block in place?
Re: php mail() on free webspace
15-11-2016 8:12 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
On the ccgi server, the PHP mail() function used directly or via the PHPmailer interface appears to be working OK for me. Also using the PHPmailer sendmail and SMTP interfaces works OK. This is for messages sent to Plusnet and Gmail addresses.
Do you get any error notification when mail() fails to send?
Re: php mail() on free webspace
15-11-2016 8:22 PM - edited 15-11-2016 8:23 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
I've discovered that if I don't supply headers it works, but as soon as I supply a header such as "From: noreply@somewhere.com \r\n" it doesn't. Of course I need to supply a header, mail is always returning true.
On another page I have some code that sends a simple email to 1 recipient (including headers) it's been working for weeks and today nothing no reason, just returns true like it's done it.
I've never used phpmailer or SMTP, maybe I should investigate these as an alternative
Re: php mail() on free webspace
15-11-2016 9:17 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
My test included a From: header, but since it was the last additional header it wouldn't be terminated with "\r\n". If yours is last have you tried without those characters? Presumably the From domain actually exists?
Unfortunately mail() returning TRUE only means the message has been accepted, it doesn't mean it's deliverable. Have you included an additional 5th parameter to set a bounce address? The default is effectively a blackhole. This would be like
// Additional parameter to set Envelope From/Return-Path $parameter = "-fmailboxname@username.plus.com"; if(!mail($emailTo, $emailSubject, $body, $headers, $parameter)) { echo "Message was not submitted.<br>\n"; echo "PHP mail() function failed."; exit; }
Re: php mail() on free webspace
16-11-2016 11:27 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
I'm using mail() exactly as shown on w3schools. The header is terminated with \r\n but as there is only 1 header, maybe that is not needed, I'll try that tonight (doing this after work). The from email address does not exist, its a NoReply@mydomain.com address.
Ive used that approach before and its worked, Its also worked successfully, but intermittently in the PN hosting recently.
I've not used the 5th parameter for a bounce address, I may give that a try.
Re: php mail() on free webspace
16-11-2016 6:25 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
OK, well, I seem to have resolved this.
if I use my plusnet email address (something@myusername.plus.com) as the From, like this:
$noReplyEmailAddress="test@myusername.plus.com";
$headers="From: ".$noReplyEmailAddress.$newline."Bcc: ".$bccEmailAddress;
Where $newline is "\r\n" and Bcc is a working email address.
It all seems to work as expected.
This doesnt explain why it did work previously, then stopped, started and stopped for good. Maybe there was a change behind the scenes.
Re: php mail() on free webspace
16-11-2016 11:40 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
I've done a bit of experimentation on mail() behaviour sending to a Plusnet address.
- sending works fine with or without CRLF at the end of additional headers.
- sending with the From: header set to a non-Plusnet address which exists works fine. Sending a reply to that From address (from the Plusnet recipient) works.
- sending with the From: header set to the same valid domain but with invalid local part fails and no bounce message is received at a valid bounce address.
Just wondering if spam checking is an issue here. Sending is spam checked on CCGI as is receipt at my Plusnet address.
Re: php mail() on free webspace
17-11-2016 5:20 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
@spraxyt wrote:
- sending with the From: header set to the same valid domain but with invalid local part fails and no bounce message is received at a valid bounce address.
In fact that email *did* eventually turn up but after being delayed by 2hr 13 min at handover from the ccgi mail relay and Plusnet avasin. The tracking headers are as follows:
Return-path: <bbbbbbbbb@yyyyyyyyy.force9.co.uk> Envelope-to: aaaaaaaaa@yyyyyyyyy.force9.co.uk Delivery-date: Thu, 17 Nov 2016 01:07:58 +0000 Received: from [212.159.8.109] (helo=avasin09.plus.net) by inmx03.plus.net with esmtp (PlusNet MXCore v2.00) id 1c7BBG-0002V1-EG for aaaaaaaaa@yyyyyyyyy.force9.co.uk; Thu, 17 Nov 2016 01:07:58 +0000 Received: from mailrelay3c50.megamailservers.eu ([91.136.10.252]) by avasin09.plus.net with Plusnet Cloudmark Gateway id 8p7w1u0025SGcrf01p7yT5; Thu, 17 Nov 2016 01:07:58 +0000 Received: from web92c50.megawebservers.eu ([10.130.1.92]) by mailrelay3c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id uAGMshWd003357 for <aaaaaaaaa@yyyyyyyyy.force9.co.uk>; Wed, 16 Nov 2016 22:54:43 +0000 Received: (from ccgi.yyyyyyyyy.force9.co.uk@localhost) by web92c50.megawebservers.eu (8.14.4/8.12.2/Submit) id uAGMsrHE017577; Wed, 16 Nov 2016 22:54:53 GMT Date: Wed, 16 Nov 2016 22:54:53 GMT Message-Id: <201611162254.uAGMsrHE017577@web92c50.megawebservers.eu> To: aaaaaaaaa@yyyyyyyyy.force9.co.uk MIME-Version: 1.0 Content-type: text/html; charset=iso-8859-1 From: idontexist@validdomain.co.uk Subject: Testing use of mail() with invalid From address
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Plusnet Community
- :
- Forum
- :
- Help with my Plusnet services
- :
- Everything else
- :
- Re: php mail() on free webspace