Send Mail By Php Mail() Function
I have problem with sending mail message by php mail() function. I'm not sure if it's problem with code coz I have read that some hosting servers are not allowing to sends mail but
Solution 1:
To test that sending of email works, try this really short program:
<?php$email_to="address@gmail.com";
$email_subject="It works";
$email_message="Hello. I can send mail!";
$headers = "From: Beacze\r\n".
"Reply-To: address@gmail.com\r\n'" .
"X-Mailer: PHP/" . phpversion();
mail($email_to, $email_subject, $email_message, $headers);
echo"mail sent!"?>
I have used one "just like it" in the past as the starting point for testing a configuration. If this doesn't work it's most likely your server configuration.
Solution 2:
You can use SMTP (phpmailer) Example:
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->CharSet = 'UTF-8';
$mail->Host = "mail.example.com"; // SMTP server example$mail->SMTPDebug = 0; // enables SMTP debug information (for testing)$mail->SMTPAuth = true; // enable SMTP authentication$mail->Port = 25; // set the SMTP port for the GMAIL server$mail->Username = "username"; // SMTP account username example$mail->Password = "password"; // SMTP account password example
You can find more about PHPMailer here: https://code.google.com/a/apache-extras.org/p/phpmailer/
Post a Comment for "Send Mail By Php Mail() Function"