MWEB Hosting, PHP Mail function, Help please

GreGorGy

BULLSFAN
Joined
Jan 18, 2005
Messages
15,290
Reaction score
1,527
Location
Benoniebfkweesnie
One of my clients hosts with Mweb and the php mail function seems to be all but dead. Anyone else here host with them that can tell me what MWEB expects from the mail function. Even this basic code fails:

Code:
<?php

if (mail("[email protected]", "Test message", "This is the message", "From: [email protected]
")) {echo "Success!";} else {echo "Failed";}

?>
 
Hmm, that's weird.....

Email support (or rather phone) and ask them to take a look at it.
It should be working fine, as I use it on a client's site (hosted at Mweb) and it works fine.
 
One of my clients hosts with Mweb and the php mail function seems to be all but dead. Anyone else here host with them that can tell me what MWEB expects from the mail function. Even this basic code fails:

Code:
<?php

if (mail("[email protected]", "Test message", "This is the message", "From: [email protected]
")) {echo "Success!";} else {echo "Failed";}

?>

Post your form code here and I will write you a mail handler
 
I don't host with MWEB, but I would like to point something out:

Code:
mail("[email protected]", "Test message", "This is the message", "From: [email protected]
")

The From field part of the DATA portion of the mail. It is ignored by the mail server. The mail server cares about the envelope sender, and you're not setting the envelope sender, so your mail is going to come from something like [email protected] or whatever they call their boxes. Check the headers for the "Return-path" header

You need to do something like:

Code:
mail("[email protected]", "Test message", "This is the message", "From: [email protected]
", "[email protected]")

The -f is passed to the sendmail binary and sets the envelope sender.
 
Last edited:
Code:
mail("[email protected]", "Test message", "This is the message", "From: [email protected]
", "[email protected])

The -f is passed to the sendmail binary and sets the envelope sender.



Hey - you wanna make me spend even more time on this? Because the code above will of course bail :)

Missing " at end....

Ja, I am aware. I wanted to reduce this mail function to the very bare basics. The code above is stored as testmail.php on the route of their website and has nothing else. It fails to send mail. At the very least, all other semantics aside, it should try to send something.

Byron: with all due respect, I have had the form working for a long time - it has recently started misbehaving. It is not the code but the server. They have just told me now (on the phone) that I need to explicitly set the sendmail path. I can write my own handlers quite beautifully thanks :)
 
Does MWeb uncapped hosting (the R19 per month) thing have support for PHP5 and MySQL database? How much space for databases do you get?
 
Yes, and 50MB (1 database).

Sorry to open up an old thread but was there a solution found to this?

here is my code im using and have the same issue

<?php

$to = '[email protected]';
$subject = 'Enquiry from the website';
$contact_submitted = 'Your message has been sent.';

// Do not amend anything below here, unless you know PHP
function email_is_valid($email) {
return preg_match('/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i',$email);
}
if (!email_is_valid($to)) {
echo '<p style="color: red;">You must set-up a valid (to) email address before this contact page will work.</p>';
}
if (isset($_POST['contact_submitted'])) {
$return = "\r";
$youremail = trim(htmlspecialchars($_POST['your_email']));
$yourname = stripslashes(strip_tags($_POST['your_name']));
$yourmessage = stripslashes(strip_tags($_POST['your_message']));
$contact_name = "Name: ".$yourname;
$message_text = "Message: ".$yourmessage;
$user_answer = trim(htmlspecialchars($_POST['user_answer']));
$answer = trim(htmlspecialchars($_POST['answer']));
$message = $contact_name . $return . $message_text;
$headers = "From: ".$youremail;
if (email_is_valid($youremail) && !eregi("\r",$youremail) && !eregi("\n",$youremail) && $yourname != "" && $yourmessage != "" && substr(md5($user_answer),5,10) === $answer) {
mail($to,$subject,$message,$headers);
$yourname = '';
$youremail = '';
$yourmessage = '';
echo '<p style="color: blue;">'.$contact_submitted.'</p>';
}
else echo '<p style="color: red;">Please enter your name, a valid email address, your message and the answer to the simple maths question before sending your message.</p>';
}
$number_1 = rand(1, 9);
$number_2 = rand(1, 9);
$answer = substr(md5($number_1+$number_2),5,10);
?>

Hosted with mweb.... mails sent from the site come thru extremely slow, or not at all
 
The solution was given in this thread. Just add the sendmail header as described
 
Top
Sign up to the MyBroadband newsletter
X