0

I want to send emails using php mail() function using xampp on ubuntu. But its not sent. Please check my code. Do I need to set any email server like gmail for it or I can do it without gmail?

<?php
$address = "kthakkar@argusoft.com";

$subject = 'Test email';

$body = 'If you can read this, your email is working.';

echo "Attempting to email $address...<br />";

if (mail($address, $subject, $body)) {
        echo 'SUCCESS!  PHP successfully delivered email to your MTA.  If you don\'t see the email in your inbox in a few minutes, there is a problem with your MTA.';
} else {
        echo 'ERROR!  PHP could not deliver email to your MTA.  Check that your PHP settings are correct for your MTA and your MTA will deliver email.';
}

?>

If I use smtp gmail account, its sending mails but not using php mail() as I dont want to share my gmail credentials.

Karan
  • 31
  • 5

1 Answers1

0

try this: How to configure XAMPP to send mail from localhost?

You can use other mail services, not only gmail. Later, when you have your own server, install your mail server :)

Community
  • 1
  • 1
Ivan Vulović
  • 2,147
  • 6
  • 27
  • 43