Php Mail

Status
Not open for further replies.

blackviperofdeath86

New Member
Messages
4
Reaction score
0
Points
0
I'm trying to use Php's mail() function, but no emails seem to send. I had a co-worker test the code with his server (GoDaddy), and it sent the email for him. I looked, and it appears that the function is setup, but is there an additional step I need to do in order for the function to work properly?
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
The following works on Chopin. It even gets to Hotmail (you might have to check the Spam folder, at least it does not get bounced back).

PHP:
<?php


//  TEST OF THE MAIL SYSTEM USING PHP mail()

date_default_timezone_set('America/Los_Angeles');
echo date('l jS \of F Y h:i:s A'); 
echo "\n";

$from = "myX10cPanelName@myX10domain.x10.bz";
$to="myGMAILaccount@gmail.com"; 


$mailbody="Test message sent (PST): \n" . date('l jS \of F Y h:i:s A');
$subject="Test of PHP mail()" ;

$headers = "Content-type: text/plain; charset=windows-1251 \r\n";
$headers .= "From: $from\r\n";
$headers .= "Reply-To: $from\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "X-Mailer: PHP/" . phpversion();

$resp = mail($to, $subject, $mailbody, $headers);

if( $resp ){
    $outcome = "Mail sent" ;
} else {
    $outcome = "Mail not sent";
}

print "\nThe mail system said: $outcome\n\n" ;
exit();

Note: Content-type must be text-plain
Note: From header must be an account on your site.
 

blackviperofdeath86

New Member
Messages
4
Reaction score
0
Points
0
I have a similar code:

$to = "<EMAIL ADDRESS HERE>";
$subject = "test email";
$from = "From: Webhost<donotreply@email.com>";
$message="This is a test email.";

$mail = mail($to,$subject,$message,$from);

but this doesn't seem to work, and my spam folder is empty.
I tested this with both yahoo and hotmail.

Note: From header must be an account on your site.

Does this necessarily have to be true? The test that my co-worker ran worked just fine, and it's a non-existent email account.

also, my server uses boro?

Hosting package adfree-infinity
Server Name boru
cPanel Version 11.30.2 (build 1)
Theme x3
Apache version 2.2.19
PHP version 5.3.6
MySQL version 5.1.57-rel12.8
Architecture x86_64
Operating system linux
Path to sendmail /usr/sbin/sendmail
 
Last edited:

blackviperofdeath86

New Member
Messages
4
Reaction score
0
Points
0
Ok, I see why it didn't work. The from field does have to be from the domain, but the user does not have to be.

Other than that, it does not have to be in plain text either (It's just a specifier)
 
Status
Not open for further replies.
Top