PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, July 3, 2022

[FIXED] How to send emails from local host?

 July 03, 2022     php, xampp     No comments   

Issue

I made a webpage to send emails and I am using XAMPP as local host. While I am receiving this warning:

Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\sendMessage\acknowledge.php on line 12

Here is my code. line 12 is marked:

<?php
$headers = "";
if (isset($_POST['email'])){
    $to = 'anthonylaw8910@gmail.com';
    $subject = 'message from site';
    }
$message = 'Name: '.$_POST['name']."\r\n\r\n";
$message.= 'Email: '.$_POST['email']."\r\n\r\n";
$message.= 'Comments: '.$_POST['comments'];
$headers = "From: bakery@gmail.com\r\n";
$headers.= 'Content-Type: text/plain; charset=utf-8';
//check line 12 below:
$success = mail($to, $subject, $message, $headers);
?>

This is just a practice for myself and I do not have a server. How do I make it work in this circumstance?

Thanks a lot for your help.


Solution

You need to be running a mail server locally. If this is Unix, enable sendmail If this is Windows install the Simple Mail Transfer Server (not sure if the name is correct) component of IIs. E.g. for windows 2003 follow this: http://msdn.microsoft.com/en-us/library/8b83ac7t.aspx



Answered By - FarZan Takhsha
Answer Checked By - Mary Flores (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing