Encountering a problem when attempting to send an HTML email through PHP

Trying to use PHP to send email within an HTML code snippet. Here's the code I've written:

<?php
    if($_SERVER['REQUEST_METHOD'] == 'POST')
    {
        if ( mail ('<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6d0c05001e070c050c032d0a000c04_save">[email protected]</a>','New Website message' ,$_POST['message']))
             $status = "Thank you for your message";    
    }
    if ( isset($status))
        echo $status;
 ?>
  <html>
    <head>
        <title>
            Resolved Issue
        </title>
    </head>

    <body>
        <h1>
            Contact Form
        </h1>

        <form action = "" method = "post">
            <ul>
                <li>
                    <label for = "name"> Name: </label>
                    <input type = "text" id="name"name = "name">
                </li>

                <li>
                    <label for = "email" > Email: </label>
                    <input type="email" id="email" name = "email">
                </li>
                <li>
                    <label for = "messsage" > Message: </label><br>
                    <textarea name = "message" id="message"></textarea>
                </li>
                <li>
                    <input type = "submit" value= "submit">
                </li>
            </ul>
        </form>
    </body>
</html>

I encountered this error:

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:\wamp\www\form.php on line 4

Any recommendations on how to address this issue at line 4 in the php.ini file?

Answer №1

To configure your mail server in PHP, access your php.ini file and locate the section labeled [mail function]. Update the SMTP settings with the details of your mail server. Remember to restart your web server for changes to take effect.

[mail function]
; For Windows systems.
SMTP = mail.example.com
smtp_port = 587

; For Windows systems.
;sendmail_from = <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e08d85a0a79a839f829e97dcc19795">[email protected]</a>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Issue with jQuery and AJAX on the webpage

I've recently implemented the search functionality using AJAX jQuery, but I am facing a problem. Currently, when I type something in the search field, the search list displays accordingly. However, upon refreshing the page, the search results disappea ...

jQuery Conditional String Manipulation

I have set up a system where users can input values and make selections from a drop-down menu, which then get integrated into JavaScript code to generate customized sentences based on their inputs. Once the user clicks submit, the sentence is formed. It&ap ...

Creating a series of scalable svgs of uniform size in a row, enabling me to resize them based on width without disrupting the overall design

I need a row of equally sized SVGs with some text below them, like a navigation bar but larger. I almost have it working, but there are some issues with my current setup. To clarify, this is what I am aiming for: The SVGs should be responsive and scale a ...

Preventing default behavior in a JQuery post request

Encountering an issue with jQuery functionality on a mobile device. function send() { $.post("scripts/post.php", { username: $("input[name=username]").val(), password: $("input[name=password]").val() }, function(data) { if ($(".data div" ...

Assistance with HTML and CSS to position an image in the corner

I need assistance with positioning a corner image on top of another image. I want the span, which has a small background image, to be in the top left corner of the main image. Below is my code: <div id="wrapkon"> <span style="width: 4px; height: ...

Transitioning images smoothly and responsively with jQuery, creating a beautiful

Hey there! I'm looking for some help with transforming this jQuery effect. Instead of having fixed sized images, I want to set the size in percentage (width:100%; height:auto) so they can be responsive. Any creative ideas or suggestions? <scri ...

Click on the button to convert the content of the text area into a variable

Is there a way to capture all the text inside a textarea or input field as a variable upon button click using jQuery or JavaScript? The .select() function doesn't seem to achieve this, instead displaying numerous CSS properties when logged. What app ...

Learn how to incorporate a newly created page URL into a customized version of django-oscar

Just starting out with django-oscar and trying to set up a new view on the page. I've successfully created two pages using django-oscar dashboard, https://ibb.co/cM9r0v and added new buttons in the templates: Lib/site-packages/oscar/templates/osca ...

Is it possible to send emails from a local server to Gmail, Yahoo, or Rediff?

Currently, I am developing a feature that allows users to send emails to any recipient including Yahoo and Gmail. Below is the code snippet for my contact form: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1 ...

Setting up aspell or pspell on your XAMPP server

I am working on developing a web application using PHP to verify if a word is valid or exists in the English language dictionary. However, I find the instructions unclear and many of the solutions on Stack Overflow seem outdated. Can you please provide me ...

Unable to execute project using CodeIgniter

I'm facing an issue with my current project. Unfortunately, I can't share the website due to confidentiality reasons. I apologize for any inconvenience this may cause. The project is built on the CodeIgniter framework, and it runs smoothly on lo ...

Various image dimensions cause divs to shift unevenly

Here is the current setup: <div class="row"> <div class="col-md-4 content-column"> <img class="btn-center btn-desktop" src="images/buttons/btn-desktop.svg" alt="desktop button"> <h2 class="btn-deskt ...

Step-by-step guide on using JQuery to listen to an event and dynamically add a p element after a button, with the feature to remove it on click

I need to implement a functionality where clicking a button will add a new paragraph after the button, and then be able to remove that paragraph by clicking on any word within it. Any guidance on how to achieve this would be highly appreciated. Thank you! ...

Is it possible to switch from a dropdown menu to radio buttons?

I am looking to change the dropdown menu in my search section into radio buttons. Currently, when I select something from the dropdown menu, the search fields are altered. Here is the code for the dropdown menu: <select id="qs_category" name="qs_catego ...

Tips for positioning the overlay to match the icon list when hovering- JavaScript/Cascading Style Sheets (CSS)

My challenge involves a list of <li>'s accompanied by an icon that, when hovered over, displays an overlay containing information about the 'test'. The setup looks something like this: test1 test2 test3 and so forth.... Here' ...

Hovering does not activate the CSS dropdown

I have been struggling to implement a pure CSS menu that shows on hover. Although everything seems to work fine, I encounter an issue when trying to hide and then show the menu again upon hover. Here is the HTML code: <ul id="nav-menu"> <li& ...

I require fixed headers that no longer stick once reaching a specific point

I have a setup where the names and occupations of participants are displayed next to their artworks, and I've made it sticky so that as we scroll through the images, the names stay on the left. Now, I want the names to scroll out once the images for e ...

What is the best method for incorporating a YouTube embedded video into an image carousel using HTML and CSS?

I'm encountering an issue with my product carousel that includes an image and a video. The image displays correctly, but when I attempt to click on the video to have it appear in the main carousel view, it doesn't function as expected. Here is a ...

FreeTDS does not properly display UTF-8 symbols in its output when using UTF-8 encoding

While working on a MSSQL query using FreeTDS in my PHP application, I encountered an issue where special UTF-8 symbols were not being displayed. My odbc.ini files are configured as follows: [test] host = server.com port = xxxxx tds version = 7.4 clien ...

Internet Explorer versions 9 and 10 do not support the CSS property "pointer-events: none"

In Firefox, the CSS property pointer-events: none; functions properly. However, it does not work in Internet Explorer 9-10. Are there any alternative approaches to replicate the functionality of this property in IE? Any suggestions? ...