mail() funtion

Status
Not open for further replies.

1986mi35

New Member
Messages
6
Reaction score
0
Points
0
Hi there, I have switched host providers, because my previous provider, did not support imap function witch you guys do. But now I have dicovered that the mail() funciton in php is not working. I am using exatly the same code I was using on my previous host and there it was working alright. I tried to search you forum with no luck. Can you please, tell me if there is anything I need to set etc. I am going to be upgrading to a premium account providing all my code is working here, as far as I can tell right now everyhting apart from the mail() funtion is working. Thank you for your time
 

Anna

I am just me
Staff member
Messages
11,783
Reaction score
595
Points
113
Free and premium does differ a bi in setup, with free hosting having some spam preventing limitations to mail functions. If I'm not misinformed it is required that a valid from address is used (in other words a from address that actually exist in your account).

Mail() would normally be working, but I have heard from others on the same server as you are that there's something a bit messed up with it after the recent changes done.
 

1986mi35

New Member
Messages
6
Reaction score
0
Points
0
Thank you for your respond Anna I do appreciate it,
but unfortunetly it did not solve my problem, is there any more info you can give me ?
Is there someone I should contact ... I have created an email account called admin. The code below was running just fine on my previous host. I realise that you probably dont look at the code and dont offer any advise on code, I am only sending it to demestrate that the code is valid.
Thank you for you time.

$to="example@googlemail.com";
$from = "admin@biotechwihz.pcriot.com";
$subject = "Transcript";
$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";

$message = '<html>
<body>
test
</body>
</html>';
mail($to, $subject, $message, $headers);
 

1986mi35

New Member
Messages
6
Reaction score
0
Points
0
Right the mail function appears to be working now. Thank you for restoring this service.
Here is the code that works, for anyone who might be intrested.

Download php mailer from the link below
http://code.google.com/a/apache-extras.org/p/phpmailer/downloads/list

require("PHPMailer_5.2.0/class.phpmailer.php");
$mail = new PHPMailer();

$mail->From = "your_emaila_ccount@your_domain.com";
$mail->FromName = "Admin";
$mail->AddAddress("examle@example.com"); // This is the adress to witch the email has to be send.
$mail->Subject = "An HTML Message";
$mail->IsHTML(true); // This tell's the PhPMailer that the messages uses HTML.
$mail->Body = "Hello, <b>my friend</b>! \n\n This message uses HTML !";
$mail->AltBody = "Dear Sir/Madam \n\n This message uses HTML, but your email client did not support it !";

if(!$mail->Send()) // Now we send the email and check if it was send or not.
{
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
}
else
{
echo 'Message has been sent.';
}
 
Status
Not open for further replies.
Top