Hi folks,
I'm having trouble using the mail() function on GoDaddy. They're saying that it's been tested and it works fine, but my messages keep getting rejected by the mail server. Does this little test script look OK to you? It keeps returning FALSE. Thanks for your help.
===
<?php
$to = 'keith@tangoking.com';
$subject = 'test email';
$message = 'this is a test';
$headers = 'keith@tangoking.com';
echo 'hi!<br><br>';
if (mail($to, $subject, $message, $headers) == TRUE)
{
echo 'TRUE';
} else {
echo 'FALSE';
}
?>
mail() test script: please take a quick look :)
Moderator: General Moderators
Re: mail() test script: please take a quick look :)
use swiftmailer.
Dont you need a password to send your emails?
Dont you need a password to send your emails?
Re: mail() test script: please take a quick look :)
That mail script would almost guarantee you a spot in someones spam box..
it would be a smarter idea to include at least some basic header information with the email to reduce the risk.
here is a sample script:
it would be a smarter idea to include at least some basic header information with the email to reduce the risk.
here is a sample script:
Code: Select all
// multiple recipients
$to = 'there1@example.com' . ', '; // note the comma
$to .= 'there2@example.com';
// subject
$subject = 'Your Plain Text Subject, This can come from a form too, just make sure you sanatize it.. ';
// message
$message = 'You HTML message here.. This can come from a form too, just make sure you sanatize it.. ';
// 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: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Your Name <youremail@example.com>' . "\r\n";
$headers .= 'Cc: another1@example.com' . "\r\n";
$headers .= 'Bcc: another2@example.com' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);Re: mail() test script: please take a quick look :)
Thanks for the replies, folks!
This script was written simply to prove that something between their php mail() script and their mail server is choking--and it did it's job. The problem is affecting everyone on the server; all email from this server is getting rejected.
They used the good ole' "it's not our server it's your script" routine on two calls to tech support. Then I dug in and wrote a script that allowed them to use mail() to email any address. I demonstrated that it worked fine on two other servers, but crashed on theirs. In response to "It's your script" I was ready with, "If my script isn't sending email properly then why are you able to send yourself an email with it?"
So basically I had to grab them by the koulyans before they'd take a closer look. I was told that they've been working on this problem since 5am. As developers, we all know what that means.
At least they've acknowledged that there's a problem.
Unless you're using a whitelisted email marketing tool, most messages will end up in the spam box anyway.kurbot wrote:That mail script would almost guarantee you a spot in someones spam box.. it would be a smarter idea to include at least some basic header information with the email to reduce the risk.
This script was written simply to prove that something between their php mail() script and their mail server is choking--and it did it's job. The problem is affecting everyone on the server; all email from this server is getting rejected.
They used the good ole' "it's not our server it's your script" routine on two calls to tech support. Then I dug in and wrote a script that allowed them to use mail() to email any address. I demonstrated that it worked fine on two other servers, but crashed on theirs. In response to "It's your script" I was ready with, "If my script isn't sending email properly then why are you able to send yourself an email with it?"
So basically I had to grab them by the koulyans before they'd take a closer look. I was told that they've been working on this problem since 5am. As developers, we all know what that means.
Re: mail() test script: please take a quick look :)
Not 100% true,Unless you're using a whitelisted email marketing tool, most messages will end up in the spam box anyway.
setup of some RDNS records and putting in SPF records will drastically reduce your emails hitting a spam box.. Adding proper mailing functions on top of the first two methods will reduce it even further..
It comes down to HOW easily the receiving server can verify that you are a legitimate sender, and simply using the mail() function goes out from the server as root, so there is no way for the end server to "easily" validate it. Even using SMTP would be better..
Plus any addition spam checking software and filters that may be setup to check messages for body content and subject matter..
But email spam in its basics are how easy you are to identified as the sender..
Not trying to step on peoples toes here, just want the original poster here to know, that using the mail function may not work as was intended..
Re: mail() test script: please take a quick look :)
Hmm.... good points.kurbot wrote:Not 100% true, setup of some RDNS records and putting in SPF records will drastically reduce your emails hitting a spam box.. Adding proper mailing functions on top of the first two methods will reduce it even further.. It comes down to HOW easily the receiving server can verify that you are a legitimate sender, and simply using the mail() function goes out from the server as root, so there is no way for the end server to "easily" validate it. Even using SMTP would be better.. Plus any addition spam checking software and filters that may be setup to check messages for body content and subject matter.. But email spam in its basics are how easy you are to identified as the sender..Not trying to step on peoples toes here, just want the original poster here to know, that using the mail function may not work as was intended..Unless you're using a whitelisted email marketing tool, most messages will end up in the spam box anyway.
So then, what do you think of writing a script to "wash" an email list?