David Beach
New Member
- Messages
- 17
- Reaction score
- 0
- Points
- 1
dsfdsf
Last edited:
I believe that the header should end with a blank line.
Using mail() is hard to get right and I'm pretty sure the PHP devs don't intend for it to be called directly. I use a PHP email library called Ultimate Email Toolkit, but there are others like PHP Mailer, Swift Mailer, etc. I recommend using one of those. Some mail hosts do block the mail() function but PHP will emit an error.
As a side note, your code possibly has a security vulnerability in it: You aren't sanitizing inputs. For example, $_SERVER["HTTP_..."] vars are able to be spoofed by a client. A good email library will properly sanitize areas of potential user input for you.
I made a copy of your code in post #6 (above) - and changed as shown belowJust to clarify the X10 email address i have is: david.beach@sandybeachit.x10.mx this is listed in my email accounts and is live.
<?php
// added this next line
error_reporting(E_ALL);
$boundary=md5(uniqid(rand()));
//$header .= "From:Name<david.beach@sandybeachit.x10.mx>\n";
//$header .= "Reply-To:Name <david.beach@sandybeachit.x10.mx> \n";
// replaced [ .= ] with [ = ] in this next line
$header = "From:Name<(Email address in my account)>\n";
$header .= "Reply-To:Name <(Email address in my account)> \n";
$header .= 'MIME-Version: 1.0'."\r\n";
$header .= "Content-type: multipart/alternative;boundary=$boundary\n";
//$adres = "sandy.beach.it@gmail.com";
$adres = "(my Gmail address)";
$subject = "subject";
$message = "This is multipart message using MIME\n";
$message .= "--" . $boundary . "\n";
$message .= "Content-type: text/plain;charset=iso-8859-1\n";
$message .= "Content-Transfer-Encoding: 7bit". "\n\n";
$message .= "Plain text version\n\n";
$message .="--" . $boundary . "\n";
$message .="Content-type: text/html;charset=iso-8859-1\n";
$message .= "Content-Transfer-Encoding: 7bit". "\n\n";
$message .="<html>
<body>
<center>
<b>HTML text version</b>
</center>
</body>
</html>\n\n";
$message .= "--" . $boundary . "--";
if(mail($adres, $subject, $message, $header))
{
print'message sent';
}
else
{
print'message was not sent';
}
?>
Does no-reply exist on your domain? You're not allowed to spoof the From header, and the address used must correspond to an email account that exists on your hosting account. (The idea is to prevent phishing.)
I made a copy of your code in post #6 (above) - and changed as shown below
My free-hosting account is on [ xo3 = (old Level) - IP: 198.91.81.3 ]
other members of my computer club tested this script on the other two (2) free-hosting servers
we had no issues with it - and I received the Emails from - all three (3) free-hosting servers - in my Gmail account