php function mail() not working

Status
Not open for further replies.

nalapachakam.in62

New Member
Messages
24
Reaction score
0
Points
1
I tried but mail() not working

Test script:


<?php
$to = "recipient@example.com";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
?>


---------- Post added at 11:07 AM ---------- Previous post was at 11:00 AM ----------

Another Test Script:

<?php

$send_html_messages = "no";
$adminmail="admin@nalapachakam.in"; //change to your adminmail
$useremail="nalapachakam.in@gmail.com"; //change to your own personal mail
$subject = "subject test";
$content = "test content";
$xheaders = "From: " . $adminmail . " <" . $adminmail . ">\n";
$xheaders .= "X-Sender: <" . $adminmail . ">\n";
$xheaders .= "X-Mailer: PHP\n"; // mailer
$xheaders .= "X-Priority: 6\n"; // Urgent message!
if ($send_html_messages == "yes") {
$xheaders .= "Content-Type: text/html; charset=iso-8859-1\n"; // Mime type
}
mail("$useremail","$subject","$content",$xheaders);

if (mail("$useremail","$subject","$content",$xheaders)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
?>


Everything failed.... Please help.. iam on free hosting now> mail() worked for me before....
 
Last edited:

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
1.
Code:
f ($send_html_messages == "yes") {
$xheaders .= "Content-Type: text/html; charset=iso-8859-1\n"; // Mime type
}

can get your mail quietly swallowed by the server. HTML emails are not allowed

2.
Code:
$adminmail="admin@nalapachakam.in"; //change to your adminmail

Since this is used for the "From" header, it must be an email account on your domain. Otherwise, it will be swallowed. Forging headers is not allowed.

3. You are on the server Boru and apparently the mail system for it was messed up while the current updates were going on. One user has reported that his script has now suddenly started working again.
 

ajordan91

Banned
Messages
101
Reaction score
2
Points
0
with x10hosting's free-hosting accounts - PHP mail() function is as much down as up

a PHP script will work for days - then error out for days - then start to work for days...
with no change to the code or account

I have moved all my sites - that must have Email - to other host
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Another option is to set up a Google Apps account for the domain and then route all the email through it via SMTP.
 

nalapachakam.in62

New Member
Messages
24
Reaction score
0
Points
1
Another option is to set up a Google Apps account for the domain and then route all the email through it via SMTP.

Great.. But can you simply demonstrate how to use Google Apps?

Iam having google apps setup and working for my domain...


Something like a test script to send email via smtp? where can i find smtp server details in google apps cpanel?

Please help
 
Last edited:
Status
Not open for further replies.
Top