PHP mail function and mail configuration in XAMPP and sending mail is done from sendmail through localhost. I hope it will help you.
- mail() function
- <?php
- $to = 'dubeynitish22@hotmail.com';
- $subject = 'Test';
- $message = 'Hello';
- $headers = 'From: webmaster@example.com' . "\r\n" .
- 'Reply-To: webmaster@example.com' . "\r\n" .
- 'X-Mailer: PHP/' . phpversion();
- if(!mail($to, $subject, $message, $headers)){
- echo "Error !!";
- }else{
- echo "Email Sent !!";
- }
- ?>
2. php.ini configuration (For SEND-MAIL)
- [mail function]
- ; For Win32 only.
- ; http://php.net/smtp
- ;SMTP=localhost
- ; http://php.net/smtp-port
- ;smtp_port=25
- ; For Win32 only.
- ; http://php.net/sendmail-from
- ;sendmail_from = me@example.com
- ; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
- ; http://php.net/sendmail-path
- sendmail_path ="C:\xampp\sendmail\sendmail.exe -t"
3. mail.ini (localhost)
- smtp_server=smtp.gmail.com
- auth_username=abc@gmail.com
- auth_password=abcdefg
- hostname=localhost
super
ReplyDeleteThanks !!
DeleteI receive an error so what's might be the issue
ReplyDeletesmtp_server=smtp.gmail.com
Deletesmtp_port=465
Change the port and restart Apache, Try it.
it really did help to me. thanks a lot
ReplyDeleteThanks !!
Deletewhat should the sendmail.ini file look like?
ReplyDeleteThanks
Same as mail.ini
Deletewhat is the path for mail.ini path in localhost
ReplyDeleteIt is written above , if not working let me know again.
DeleteI write same to same code in my php.ini ,sendmail.ini and mail.php file but email can't send . why?
ReplyDeleteHi Imdad,
DeleteKindly share your code on geekanswer22@gmail.com, I will check and will revert back And try it too...
smtp_server=smtp.gmail.com
smtp_port=465
Change the port and restart Apache, Try it.
Tried Same Code..But its not working
ReplyDeleteit's not working please send me a solution ?
ReplyDelete