Send email with PHP | Create a Working Contact Form Using PHP

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 ก.ค. 2024
  • Please consider supporting my channel:
    ☕ ko-fi.com/davehollingworth
    Learn how to send an email using PHP.
    Recommended hosting:
    davehollingworth.net/hosting
    Full PHP course:
    ➤ davehollingworth.net/phpy
    In this video you'll learn how to:
    • create a contact form in HTML, including client-side validation
    • install and configure the PHPMailer package
    • send email using PHPMailer
    • debug problems when sending the email
    • use the post / redirect / get pattern
    Code shown in the video:
    ➤ gist.github.com/daveh/1164348...
    Using Gmail's SMTP server:
    ➤ support.google.com/a/answer/1...
    PHPMailer:
    ➤ github.com/PHPMailer/PHPMailer
    PHPMailer documentation:
    ➤ github.com/PHPMailer/PHPMaile...
    CSS:
    ➤ watercss.kognise.dev/
    00:00 Introduction
    00:19 Create contact form
    01:32 Style the form
    02:06 Create PHP script
    02:52 Get SMTP server
    03:37 Sending email from PHP
    04:01 Install PHPMailer
    04:12 Use PHPMailer
    06:57 Debugging
    08:31 POST / redirect / GET
    09:50 Summary
    #PHP #PHPMailer #SMTP #email
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 256

  • @dave-hollingworth
    @dave-hollingworth  ปีที่แล้ว +4

    What other related topics would you like to see a video on?

    • @abanwaraphael1526
      @abanwaraphael1526 ปีที่แล้ว +6

      I would like to see sending SMS to individuals phone with PHP and also sending bulk email with PHP

    • @abanwaraphael1526
      @abanwaraphael1526 ปีที่แล้ว +1

      Thank you for this video Dave. I bought some of your courses on udemy and they have been really helpful

    • @s2003katalin
      @s2003katalin ปีที่แล้ว +3

      A similar video to this one but involving image attachments WITHOUT saving them on the server permanently. Maybe a part 2 ?
      Thank you

    • @craigc5879
      @craigc5879 ปีที่แล้ว +1

      Another great video, wouldnt mind seeing a updated video on php frameworks like code ignitor

    • @alan-williams-web
      @alan-williams-web ปีที่แล้ว

      I was going to ask for Laravel, but Dev Henry beat me to it. I'm sure you have Udemy course on Laravel?
      From a selfish perspective, I would like to see the php way of taking several user input nuber values, carrying out a calculation, and then displaying the result. I've patched together a working JS version, but still not sorted out the validations (RegEx) for the fields.

  • @getoverhere1225
    @getoverhere1225 4 หลายเดือนก่อน +11

    Is actually really frustrating that no one wants to do a tutorial a tutorial for a working email form that has the proper security features that are required by web host. That's mainly the whole reason why you would incorporate PHP into the email.

  • @StevieB86
    @StevieB86 ปีที่แล้ว +6

    I only found this channel earlier today, but I love your delivery. Really easy to understand. I will have been coding for exactly one year tomorrow and I've just finished building my first full-stack project using JavaScript and PHP. Hope you produce more PHP videos for this channel. Thanks for sharing, Dave, subscribed!

  • @Nashiuz
    @Nashiuz ปีที่แล้ว +6

    Dave is the best PHP instructor. I'm a React dev who was afraid to learn PHP. I gave his PHP course a shot and wow now I can do OOP in PHP

  • @davidh7300
    @davidh7300 ปีที่แล้ว +1

    Hi Dave! Finishing up the second Udemy MVC course man what a blessing. Gonna use this email technique with it. You taught us a lot of what I learned in college about Java in those two courses. Extremely valuable resource for up and coming developers. I am going to build a couple more frameworks using some textbooks I found and implement the best from all of them. Your framework is the baseline the router is awesome thank you! It acts like a sort of white list or catalog of pages a user can access on your site. Very cool piece of the puzzle as far as organization and access control.

  • @Shashidhara_S_C
    @Shashidhara_S_C ปีที่แล้ว +1

    I was struggling to send an email through php thanks Dave Hollingworth sir for the usefull video.💌

  • @alan-williams-web
    @alan-williams-web ปีที่แล้ว +4

    Great, Dave. This is helpful and very useful for me. Thanks for your efforts.

  • @AnnabethChase-zp6ep
    @AnnabethChase-zp6ep ปีที่แล้ว +2

    I had never heard of classless css
    this is lifechanging😭😭

  • @sampsonchinonso6058
    @sampsonchinonso6058 2 หลายเดือนก่อน +1

    I never knew you could use an smtp with php…Thank you

  • @andreivlaicu51
    @andreivlaicu51 11 หลายเดือนก่อน +1

    Easy and straight forward! Thank you

  • @ldeutscher3904
    @ldeutscher3904 9 หลายเดือนก่อน +1

    Nice job of explaining this so it makes sense! Only I want to send through my own webhost mail server, so need to find out how to do that, but Thank you, as I understand more now then I did before watching this!

  • @cristian-paraschiv
    @cristian-paraschiv ปีที่แล้ว +1

    Great, Dave. Thanks for the video.

  • @eazyxpressshippingservices5797
    @eazyxpressshippingservices5797 ปีที่แล้ว +1

    thanks very much. I learn a lot from you!

  • @Alejandro00710
    @Alejandro00710 7 หลายเดือนก่อน

    Great channel, easy to understand and very complete, subscribed already.

  • @DocRamadani
    @DocRamadani 8 หลายเดือนก่อน

    Hi Dave, thank you so much for the video. It really helped me to solve a small task very quickly! THANKS!!!!

  • @conradjelinger2120
    @conradjelinger2120 ปีที่แล้ว +1

    So doggone helpful... clear and consise. Thank you Dave.

  • @jeremyharvard6057
    @jeremyharvard6057 ปีที่แล้ว +1

    Thanks you very much for this video!

  • @user-ub8te7fy5r
    @user-ub8te7fy5r 5 หลายเดือนก่อน

    Thank you for this tutorial.

  • @comconet
    @comconet 6 หลายเดือนก่อน +1

    It worked beautifully. - Rolfe

  • @user-kr4ce6oe6u
    @user-kr4ce6oe6u 3 วันที่ผ่านมา

    thanks that is awesome straight forward tutorial

  • @adeoyemuhdfawas
    @adeoyemuhdfawas ปีที่แล้ว

    Nice video.👏🏿👏🏿👏🏿
    Thank you sir!

  • @GMCC88
    @GMCC88 ปีที่แล้ว +1

    ok, if composer was unable to install PHPMailer correctly by running:
    C:\xampp\htdocs>composer require PHPMailer/PHPMailer and I DON'T have the autoload.php file that comes with installing using composer, how does this affect the .php file that contains the instructions for sending the email using SMTP? I was able to download the zip file from the PHPMailer github post and move the PHPMailer pkg to the htdocs/vendor/phpmailer folder however

  • @dannyreg8405
    @dannyreg8405 ปีที่แล้ว

    Finally, I got phpmailer in and working. It was done all with your help and thank you. Question: How can I send two different messages to two emails address?

  • @yahayamoussamai-daboua9871
    @yahayamoussamai-daboua9871 ปีที่แล้ว +1

    Well done. Thanks a lot.

  • @marcoaureliodemesquita337
    @marcoaureliodemesquita337 หลายเดือนก่อน

    Great video, congrats!
    I'm new here, and I will check out other videos on the channel.
    Two topics that interest me would be a video about superglobal variables in PHP and how to implement a "shopping cart" on PHP and MySQL.

  • @markcorrigan293
    @markcorrigan293 ปีที่แล้ว +1

    Thanks Dave.

  • @abanwaraphael1526
    @abanwaraphael1526 ปีที่แล้ว

    Good day Dave. I have been trying to send mail on my production server using php but it keeps failing.
    However, I have tried to buy your course in PHP mailing for one two months now, and I've been successful

  • @Ritzel099
    @Ritzel099 ปีที่แล้ว +2

    omg it worked! GRACIAS!!!!! :D
    Es difícil encontrar tutoriales de esto en español ;-;

  • @anthonygeorges5828
    @anthonygeorges5828 ปีที่แล้ว +1

    Thanks you so much !!!!!!!!

  • @FGP-PIANO
    @FGP-PIANO ปีที่แล้ว

    excellent tutorial

  • @tempMahad
    @tempMahad ปีที่แล้ว +1

    PHP is so underrated, whyyyyy

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว +1

      It gets a bad reputation as it's been around so long, and it's easy to write bad code with it; having said that, it's also very easy to pick up and is available everywhere

  • @gangaghosh4726
    @gangaghosh4726 11 หลายเดือนก่อน

    Thank you soo much i got it

  • @shreelacounty9871
    @shreelacounty9871 ปีที่แล้ว +1

    IT WORKEED!!!!!! thank you

  • @ilya_123__
    @ilya_123__ 11 หลายเดือนก่อน +1

    thank you

  • @rosaprint8676
    @rosaprint8676 ปีที่แล้ว

    super, outstanding

  • @marcoantonini5569
    @marcoantonini5569 4 หลายเดือนก่อน +1

    Hi there, if I run the debugging everything just seem to work properly (the echo email sent appears after all the details) but no e-mails arrive at the written address. Any suggestions? Thanks

    • @dave-hollingworth
      @dave-hollingworth  4 หลายเดือนก่อน

      If there are no error messages from the SMTP server, then the problem could be with the recipient account - check to see if the message is in the spam folder

  • @user-xc7zl1ut5f
    @user-xc7zl1ut5f ปีที่แล้ว +1

    Hi Dave,
    Thank you for making this video! It was super helpful as a beginner to PHP. When I submit the email, it sends to the correct address, but regardless of what email I type in on my form, it will always send from the email I access my SMTP server from. I am using the Google SMTP server, but I also tried this with the Outlook SMTP server and the same thing happened. Is this just a limitation from those SMTP servers?

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว

      This is a feature of how the SMTP server works, yes. You can't send an email from someone else's account, you can only send it from the account you're authenticating with. You can use a "reply-to" however if you want someone to reply to a different address that you're sending from.

    • @AlekZkoo
      @AlekZkoo 10 หลายเดือนก่อน

      Hi, I just came by your tutorial and I'm wondering, if I make contact form using SMTP server on my website, from which email address would be an email sent? Can you even use SMTP server to make contact form since it displays only email address you're authenticanting with? Sry if this is a stupid question, but I just started with PHP. @@dave-hollingworth

  • @anandhuappu1458
    @anandhuappu1458 ปีที่แล้ว +2

    Can you make a tutorial for uploading file to server using php? A humble request.

  • @coolvibesreloaded7946
    @coolvibesreloaded7946 5 หลายเดือนก่อน

    @dave-hollingworth
    great video strait to the point unlike other videos out there :)
    quick question the sent.html send-email.php and form.html do we put those three files into phpmailer folder once it's downloaded????? please reply

    • @dave-hollingworth
      @dave-hollingworth  5 หลายเดือนก่อน

      No, those files go in your web root or project folder. The PHPMailer package goes into the same folder. (or the vendor folder if you're using Composer)

  • @AbhishekBade1310
    @AbhishekBade1310 11 หลายเดือนก่อน +1

    how do i make a smtp server

  • @burtcollymore7644
    @burtcollymore7644 ปีที่แล้ว

    Hi Dave...The intro video for the Udemy course PHP for Beginners
    Build a Content Management System from Scratch with PHP and MySQL says "Style using BOOTCAMP"...It should be, "style using BOOTSTRAP"...Cheers.

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว

      Really? Hadn't spotted that! Thank you for letting me know, I'll get that fixed :-)

  • @intransnews8282
    @intransnews8282 11 หลายเดือนก่อน

    do we still need to use gmail smtp if we have cPanel (Hosting)? i want to use smtp email from my cPanel, is that possible?

    • @dave-hollingworth
      @dave-hollingworth  11 หลายเดือนก่อน +1

      Yes of course, you can use whatever SMTP server you have access to, all you need are the hostname and connection credentials

  • @virtualdesigns4428
    @virtualdesigns4428 ปีที่แล้ว

    Estou com problemas em enviar formulario de contato de um site hospedado na locaweb. Você poderia me ajudar?

  • @Skankhunt-cf6uh
    @Skankhunt-cf6uh 2 หลายเดือนก่อน +1

    Great explaination, it also worked with my contactform.
    But how do i upload this to my online host to use from every mobile device for

    • @dave-hollingworth
      @dave-hollingworth  2 หลายเดือนก่อน

      Just upload the code you have locally, including the entire vendor folder

  • @abanwaraphael1526
    @abanwaraphael1526 ปีที่แล้ว

    Please what could be the cause for "could not connect to SMTP host" .. it was working initially

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว +1

      Enable debugging as shown in the video to see if there are any more detailed messages shown in the debugging output. That message though suggests a network issue

  • @Gracek.g
    @Gracek.g ปีที่แล้ว +1

    for my code and the one provided in the description I get the HTML Error 405 when I run it in the VSCode Live Server.
    I changed the SMTP settings accordingly to my provider. The port is set to the correct one. I can't pinpoint what's causing the issue :/

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว

      I'm afraid I'm not familiar with the VSCode live server - are you able to run it using a different server to see if it's a VSCode issue?

    • @Gracek.g
      @Gracek.g ปีที่แล้ว +1

      @@dave-hollingworth I scavenged the internet and it seems it's the VScode's live server's fault. I ran the built in PHP local host server and it works. I mean, I still get the errors but they are connected with my poor understanding of the SMTP provider I chose and not your tutorial. Thank you for the upload!

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว +1

      @@Gracek.g Ah ok good to know - I'll keep that in mind in case anyone else has a similar issue. Thanks!

    • @helloiamgeorgia
      @helloiamgeorgia 9 หลายเดือนก่อน

      I had the same issue. I got an HTML Error 405 when running index.html in the Live Server. Then I opened index.html in PHP Server and it successfully sent the message and loaded the "sent.html" page with no problem.

  • @jamiemacdonald5972
    @jamiemacdonald5972 ปีที่แล้ว

    Thanks for this great tutorial! Beginner question probably - but I consistently get a 404 on form submission. I've got the form method as "post" and the action="send-email.php", and send-email.php is all spelled correctly, etc. But I'm sure I'm missing something obvious (code is copied and phpmailer is installed via composer in VScode). Thanks again for the video.

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว

      What URL is shown in the browser's address bar when you submit the form and get the 404?

    • @jamiemacdonald5972
      @jamiemacdonald5972 ปีที่แล้ว

      @@dave-hollingworth Thanks, hadn't thought to actually look there. It's coming up as "send-email.php" in the address bar. I should specify that on the browser when I click "send" I actually get a 405 error, but in the VScode terminal it shows up as a 404 for send-email.php - not found. *edit - and I had turned on debugging mode, as per your instructions, but I still just get the same error*

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว

      @@jamiemacdonald5972 Are you developing in a subfolder of the root? E.g. localhost/subfolder/form.html
      If so, you need to include that subfolder (or don't start the action attribute of the form with a slash if you are doing)
      I'm afraid I don't use VSCode so I'm not familiar with its debugging tools

    • @jamiemacdonald5972
      @jamiemacdonald5972 ปีที่แล้ว

      @@dave-hollingworth Yep, same folder, which is why it's strange getting the 404. Anyway thanks for the help and for the video, great intro to php concepts!

    • @sorenchristenson3203
      @sorenchristenson3203 ปีที่แล้ว +1

      @@dave-hollingworth thanks Dave, you are on to something with the sub folders. Great tut, thanks.

  • @andreasorourke4252
    @andreasorourke4252 ปีที่แล้ว

    I followed all of the steps and copied the PHP code, but when I hit the send button on my HTML page my browser simply displays my raw PHP code rather than sending the email. Any advice?

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว +1

      Please see this: th-cam.com/users/shortsl7ERVQd7Ti8?feature=share

  • @nethmiyuganjana2353
    @nethmiyuganjana2353 ปีที่แล้ว

    There is no option to turn on access to less secure apps in my gmail, (google says no longer we cannot use that facility) what can i do about that?

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว

      It looks like you need to use an App password now: www.febooti.com/products/automation-workshop/tutorials/enable-google-app-passwords-for-smtp.html

  • @devhenry9054
    @devhenry9054 ปีที่แล้ว +7

    Please make laravel course

  • @maxscheel6083
    @maxscheel6083 7 หลายเดือนก่อน +1

    Would you say it's still worth it to learn PHP workwise? Thanks for easy understandable video :)

    • @dave-hollingworth
      @dave-hollingworth  7 หลายเดือนก่อน

      Absolutely, PHP is still very popular

  • @lukas584
    @lukas584 ปีที่แล้ว +1

    Unfortunately I'm not able to install the composer file through the command line (I'm using Windows shell). I changed file directory to my htdocs where my project is located. I would appreciate a more detailed explanation. Thank you in advance. Appreciate your work Dave.

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว +1

      The easiest way to install Composer on Windows is using the installer: getcomposer.org/doc/00-intro.md#installation-windows

    • @lukas584
      @lukas584 ปีที่แล้ว

      @@dave-hollingworth Thanks, it worked. Now my problem is that I'm not allowed to activate messages from third party (less secured apps)? Any ideas how I could fix this?

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว +1

      @@lukas584 www.febooti.com/products/automation-workshop/tutorials/enable-google-app-passwords-for-smtp.html

    • @lukas584
      @lukas584 ปีที่แล้ว

      ​@@dave-hollingworth Thank you Dave, I followed the given instructions and it finally worked (so happy). The thing is that I do not see who is sending me the data from the form as the email does not appear in my gmail. It's like I would send an email to myself (receiver email and sender email is both the same. It's the email which I set up in the code). Very strange, maybe I messed up with the code but I have already checked your instruction given in the video several times. Probably it's the 2 step verification, using the generated password which does not allow to communicate with third party? What are your thoughts on this one?

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว

      @@lukas584 Not sure what you mean - but if you're not getting emails you send to yourself, Gmail has been known to block this - see some of the results here: www.google.co.uk/search?q=gmail+smtp+can%27t+send+to+yourself

  • @SNAKEx197
    @SNAKEx197 6 หลายเดือนก่อน

    Is it okay to add phpmailer and my new php file to github? since it shows the password and email for the smtp.

    • @dave-hollingworth
      @dave-hollingworth  6 หลายเดือนก่อน +1

      No - you would typically store the password in a separate file, e.g. an .env file and put this in your .gitignore file so it isn't uploaded to your repo

    • @SNAKEx197
      @SNAKEx197 6 หลายเดือนก่อน

      @@dave-hollingworth ah, so it's fine to have my "mail.php" (the PHP file you created) & install phpmailer in the same environment as my work folder? ex. project-folder/
      ls:
      index.html contact.html mail.php vendor/
      How do I go about moving the username & password to a .env file.(first time hearing about .env) Will the PHP file work the same?
      Thank you Dave for the answer back, I'm new to PHP so I'm still learning atm.

  • @denisk256
    @denisk256 10 หลายเดือนก่อน

    Please Dave, can I use my personal email address for which the form is to be submitted or it should be an email registered with the website domain?

    • @denisk256
      @denisk256 10 หลายเดือนก่อน

      Because I have tried making different forms and when I upload them and run them online, form is not submitted and all I keep seeing is the else part for failure. But I'm using a personal email address which is not connected to the domain, could that be the problem?

    • @dave-hollingworth
      @dave-hollingworth  10 หลายเดือนก่อน

      @@denisk256 I'm not sure what you mean - when submitting the form, you can put in whatever email address you like, this will be sent to the recipient. When you authenticate with the SMTP server, the username is usually the same as the email address that you use as the sender. You can't send email from anyone's email address, only the one you authenticate with.

    • @denisk256
      @denisk256 10 หลายเดือนก่อน

      Could you please help me and take me through how I can authenticate with SMTP

    • @dave-hollingworth
      @dave-hollingworth  10 หลายเดือนก่อน

      @@denisk256 You just need to provide the username, password and hostname of the SMTP server

    • @denisk256
      @denisk256 10 หลายเดือนก่อน

      Is it possible to be doe using a mobile phone, coz right now I'm away from my laptop

  • @zmOe1
    @zmOe1 ปีที่แล้ว

    The send form only works if I enter my own email address in the email input field. If I enter another email it does not work.

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว

      Are you using a service like Mailgun where you can only send emails to one verified email address (for the free tier anyway)?

  • @Drugvigil
    @Drugvigil 7 หลายเดือนก่อน

    Hello bro I configured as by your tutorial. When I try to send email the form is not redirect to php. So I am not receiving email. What might be the issue?

    • @dave-hollingworth
      @dave-hollingworth  7 หลายเดือนก่อน

      Try adding the debugging code to show the SMTP debugging info

    • @Drugvigil
      @Drugvigil 7 หลายเดือนก่อน

      @@dave-hollingworth can you write me an example code here.

    • @Drugvigil
      @Drugvigil 7 หลายเดือนก่อน

      @@dave-hollingworth yes added but not showing any error. Locally

    • @Drugvigil
      @Drugvigil 7 หลายเดือนก่อน

      The message could not be sent. MAILER Error: invalid email address

    • @Drugvigil
      @Drugvigil 7 หลายเดือนก่อน

      I am having a error now as failed to connect to smtp host

  • @NoName-yw1pt
    @NoName-yw1pt 6 หลายเดือนก่อน

    7:10 I get the same error, but in my case it says line 2265 in PHPMailer.php file, which is: throw new Exception($this->lang('authenticate')); And the additional information from the debugging property says "Username and Password not accepted"

    • @dave-hollingworth
      @dave-hollingworth  6 หลายเดือนก่อน

      This would seem to suggest that the username and password you're using to authenticate with the SMTP server are incorrect

    • @NoName-yw1pt
      @NoName-yw1pt 6 หลายเดือนก่อน

      @@dave-hollingworth I'm certain they are correct. Can it suggest something else?

    • @dave-hollingworth
      @dave-hollingworth  6 หลายเดือนก่อน

      @@NoName-yw1pt Perhaps a network issue, is the SMTP server host reachable from your server?

    • @NoName-yw1pt
      @NoName-yw1pt 6 หลายเดือนก่อน

      @@dave-hollingworth Probably not, I don't know. How can I check?

    • @dave-hollingworth
      @dave-hollingworth  6 หลายเดือนก่อน

      @@NoName-yw1pt Try using the SMTP server from an email client (i.e. configure the email client to send emails using that SMTP server)

  • @chris7085
    @chris7085 ปีที่แล้ว

    04:06 what folder did u open to show this in your screen?

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว

      It's a command prompt / terminal window

    • @seo-rupindersingh5148
      @seo-rupindersingh5148 6 หลายเดือนก่อน

      @@dave-hollingworth is it windows run cmd or what?

    • @dave-hollingworth
      @dave-hollingworth  6 หลายเดือนก่อน

      @@seo-rupindersingh5148 Yes, that's one way, or look for command prompt application

  • @scholarway
    @scholarway 4 หลายเดือนก่อน

    I think it's not secure to openly share our email username and password, right? Is there a method to only provide our email address instead?

    • @dave-hollingworth
      @dave-hollingworth  4 หลายเดือนก่อน

      You're right that wouldn't be secure, but you're not openly sharing your password - this is only used to authenticate with the SMTP server, and is only on the server in the PHP code.

  • @alifelongfriend
    @alifelongfriend 9 หลายเดือนก่อน +1

    Good video, Dave. I am wondering if the form is secured in any way? Could not someone view the source and thereby gain your username and password?

    • @dave-hollingworth
      @dave-hollingworth  8 หลายเดือนก่อน

      If they view the source in the browser, they'll just see the generated HTML. PHP code is executed on the server, before this is sent to the browser, so the source code is never sent to the client.

    • @alifelongfriend
      @alifelongfriend 8 หลายเดือนก่อน

      @@dave-hollingworth is not the link to the PHP file in the action="-" (element field of the HTML file) and thereby susceptible to also being viewed? I am asking is there not a way to download and view the source of a file once the specified location is known/

    • @dave-hollingworth
      @dave-hollingworth  8 หลายเดือนก่อน

      @@alifelongfriend While you can see which file the form submits to as you say, you can't download this file to see the source code. If you request that file from the server by putting the URL in the browser's address bar (e.g. example.com/process-form.php) then you'll still get the result of the PHP code running before it gets to you. The web server always executes the PHP code before sending it to the browser, so there's no way to see the PHP code on the server in the browser.

  • @Panda._.745
    @Panda._.745 7 หลายเดือนก่อน

    Sir which software you are using

    • @dave-hollingworth
      @dave-hollingworth  7 หลายเดือนก่อน +1

      XAMPP for the server and database, Visual Studio Code for the editor

  • @deelinspiring9796
    @deelinspiring9796 ปีที่แล้ว

    I'm a junior developer and I want to ask you if this will work if I want to publish my website? Or is it only when my site is local?

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว

      Absolutely, as long as your live server has access to the SMTP server over the network (which is most likely)

    • @deelinspiring9796
      @deelinspiring9796 ปีที่แล้ว +1

      @@dave-hollingworth Thank u so much 🙏🏽🤍

  • @21-abhikhillare8
    @21-abhikhillare8 11 หลายเดือนก่อน

    Bro package is not downloading

  • @user-fq4nc7ip9i
    @user-fq4nc7ip9i 3 หลายเดือนก่อน

    Message could not be sent. Mailer Error: SMTP Error: Could not connect to SMTP host. Connection failed. stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failedSMTP server error: QUIT command failed i got this

    • @dave-hollingworth
      @dave-hollingworth  3 หลายเดือนก่อน

      If this is just a local error, there's a solution here: stackoverflow.com/questions/30556773/how-to-fix-stream-socket-enable-crypto-ssl-operation-failed-with-code-1

  • @russelmiranda4203
    @russelmiranda4203 11 หลายเดือนก่อน

    Does it still wirk when the website is hosted

    • @dave-hollingworth
      @dave-hollingworth  11 หลายเดือนก่อน

      Yes, as long as you have the necessary software like PHP installed

  • @rahmandarmaji7469
    @rahmandarmaji7469 ปีที่แล้ว

    Hi Dave, could you made course laravel on udemy?
    Thanks in advance...

  • @aijiexi
    @aijiexi 10 หลายเดือนก่อน

    My vendor folder did not show up even though I activated it in my command line. any guesses why??

    • @dave-hollingworth
      @dave-hollingworth  10 หลายเดือนก่อน

      You need to run the command line commands from your project folder

    • @seo-rupindersingh5148
      @seo-rupindersingh5148 6 หลายเดือนก่อน

      @@dave-hollingworth and how to run this??

  • @sosdto7606
    @sosdto7606 11 หลายเดือนก่อน +1

    Hi. Thanks for the video. I have a problem. I'm getting HTTP ERROR 405 when i try to sent email. Can someone help me?

    • @dave-hollingworth
      @dave-hollingworth  11 หลายเดือนก่อน

      Are you using the VSCode built-in webserver by any chance? Try using a separate server like Apache (you can get with XAMPP if you need it)

    • @sosdto7606
      @sosdto7606 11 หลายเดือนก่อน

      @@dave-hollingworth So i must transfer my project in htdocs folder in xampp, and then run it with apache?

    • @dave-hollingworth
      @dave-hollingworth  11 หลายเดือนก่อน

      @@sosdto7606 Yes, that's it

    • @sosdto7606
      @sosdto7606 11 หลายเดือนก่อน

      @@dave-hollingworth still have o problem. The following. Fatal error. SMTP error: data not accepted... I serach for it and find that the problem is that the mail->From is different with the $mail->addAddress...But what i actually want with this email form, is sending from my friend's mail for example, to my mail....If in the form, i put my email to the mail textarea, then it works..But if i put another mail , then it doesnt work..Do you have any solution..Thank you very much.

    • @dave-hollingworth
      @dave-hollingworth  11 หลายเดือนก่อน

      @@sosdto7606 When using an SMTP server, you can only send email from the account that you're authorising with, you can't send emails from anyone's account. You can add a reply-to value though if you want to suggest to the email client that a reply is sent to a different email.

  • @DetectiveSquarepants
    @DetectiveSquarepants 10 หลายเดือนก่อน

    Composer asks for a PHP.exe file during the installation process. What am I supposed to provide it exactly?

    • @dave-hollingworth
      @dave-hollingworth  10 หลายเดือนก่อน +1

      You need to have PHP already installed, so if you do you'll have a php.exe file installed somewhere on your system. I recommend XAMPP for Windows if you haven't got one already

    • @DetectiveSquarepants
      @DetectiveSquarepants 10 หลายเดือนก่อน +1

      @@dave-hollingworth Thanks, I'll look into this 👍🏻

  • @maxwell1007
    @maxwell1007 ปีที่แล้ว

    How can i use this to a webhost not localhost?

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว +1

      You can upload the code to a webhost and it will work in the same way

  • @Topo-ev2ct
    @Topo-ev2ct ปีที่แล้ว

    Hey there, thank you for your mail, can we keep the you@example and the password or do we need to change them?

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว

      You need to change them, they're just examples

    • @Topo-ev2ct
      @Topo-ev2ct ปีที่แล้ว

      @@dave-hollingworth Thank you for your answer, I managed to fix this issue indeed. How come the function header is not working? Like I just get the PHP debug page but the HTML page is not appearing.

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว

      @@Topo-ev2ct Could be many reasons - do you get a detailed error message? That should tell you where the error has occurred, in what script and on what line

    • @Topo-ev2ct
      @Topo-ev2ct ปีที่แล้ว

      @@dave-hollingworth not really a detailed error, whenever I press on the send error, i just get a white page and that's it, the mail does indeed get sent but i am not able to head on another pages (as the header itself should do)

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว

      @@Topo-ev2ct A blank white page usually means an error has occurred but PHP isn't configured to display it - try adding these lines to the top of your code:
      ini_set('display_errors', '1');
      ini_set('display_startup_errors', '1');
      error_reporting(E_ALL);

  • @tv44-alternative23
    @tv44-alternative23 2 หลายเดือนก่อน

    What program are you using to open and editing files also dos this program comes with a command-line terminal?

    • @tv44-alternative23
      @tv44-alternative23 2 หลายเดือนก่อน +1

      i found out already, thank you.

  • @webdesigntom
    @webdesigntom 6 หลายเดือนก่อน

    Why is this coming from my email to an the customer email instead the other way around. In the setFrom () I put $name and $email and expected this to be their name and email. Not my name and email. 🤔🤔🤔

    • @dave-hollingworth
      @dave-hollingworth  6 หลายเดือนก่อน +2

      You can only send email from the account you're authenticating on the SMTP server with; i.e. you can't send email from someone else arbitrarily

    • @webdesigntom
      @webdesigntom 6 หลายเดือนก่อน

      @@dave-hollingworth thanks so much. So how will I know the system is working before I put the site up?

    • @dave-hollingworth
      @dave-hollingworth  6 หลายเดือนก่อน +1

      @@webdesigntom Try it with another email address, you can always use a throwaway email address just to test it, or a service like mailtrap

    • @webdesigntom
      @webdesigntom 6 หลายเดือนก่อน

      @@dave-hollingworth ok thank you. That leads me in a direction. I was using another one of my emails. I am just confused because I have a field to allow potential customer to put in their email (I used an alternate one) and it was coming to that email instead of my email so I'll have to learn better how to make it work. But thanks again and you've been a big help. Got yourself a subscriber.

  • @lanyiming
    @lanyiming ปีที่แล้ว

    Hello sir
    I watched your video and tried to install PHPMailer successfully. PHPMailer can work normally on the website set up by XAMPP on the local computer, but PHPMailer cannot work normally when the webpage is uploaded to the PHP website environment on synology , have you ever encountered this problem?

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว

      I'm afraid not, I haven't used Synology - it sounds like it's a permissions or network problem if the code works locally - I would suggest contacting their technical support

  • @ethe662
    @ethe662 8 หลายเดือนก่อน

    hi, i am struggling with 405 error assistance please

    • @dave-hollingworth
      @dave-hollingworth  8 หลายเดือนก่อน

      Try using a web server instead of VSCode's built-in web server

    • @ethe662
      @ethe662 8 หลายเดือนก่อน

      @@dave-hollingworth Yes, I have been looking at countless videos on this 405 and I haven't gotten any head way

  • @khancross
    @khancross ปีที่แล้ว

    After submitting the form, error occur:
    This page isn’t working
    DOMAIN is currently unable to handle this request.
    HTTP ERROR 500

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว

      A 500 error is an error on the server, most likely an error in the code - try adding these lines to the top of your PHP:
      ini_set('display_errors', '1');
      ini_set('display_startup_errors', '1');
      error_reporting(E_ALL);
      This will show the error detail instead of the 500 error.
      Alternatively, look in the web server's error log to see the error detail.

    • @khancross
      @khancross ปีที่แล้ว

      @@dave-hollingworth I think your example PHP file is faulty. Check the file at the lower bottom where the HTML part starts.

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว

      @@khancross Please can you be more specific? Which file and which line do you think is faulty?

    • @khancross
      @khancross ปีที่แล้ว

      @@dave-hollingworth send-email.php file is faulty. Check last lines in the document

    • @khancross
      @khancross ปีที่แล้ว

      Sorry I made a mistake. However where is the autoload.php?

  • @thestorytellerpk
    @thestorytellerpk 9 หลายเดือนก่อน

    I have tried all but no success, it not working, how to share my code with you?

    • @dave-hollingworth
      @dave-hollingworth  9 หลายเดือนก่อน

      You can put a link to Pastebin, GitHub etc. here

  • @increment-
    @increment- ปีที่แล้ว

    Can users also upload their files with this form?

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว

      Yes, you could modify the form to have a file attachment, and attach files using PHPMailer

    • @increment-
      @increment- ปีที่แล้ว

      @@dave-hollingworth Thank you so much! Great video 👍

  • @rudyredline
    @rudyredline 11 หลายเดือนก่อน

    Thank you but why does the script need a password to send an email?

    • @dave-hollingworth
      @dave-hollingworth  11 หลายเดือนก่อน

      To authenticate with the SMTP server.

  • @user-mz5iw7si4f
    @user-mz5iw7si4f 6 หลายเดือนก่อน

    PHP with Gmail is not working anymore,, I tried that many times

  • @kostaspapadopoulos3767
    @kostaspapadopoulos3767 ปีที่แล้ว

    Thanks for this great vid! Is this approach safe from scammer bots accessing my login data?

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว

      As far as I know, yes - I'm not sure how a bot could get your login data from this, unless your server was compromised and they had access to your source code with your credentials in it.

  • @abanwaraphael1526
    @abanwaraphael1526 ปีที่แล้ว

    Please I have been trying to get your course on udemy on Sending Email with PHP. I've not been able to make purchase. I have been debited twice for that same course , yet is has not been successful. Write to udemy. I have also written to them I may not the only one having the challenge

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว +1

      Ok I will mention it to instructor support, thank you for letting me know

    • @abanwaraphael1526
      @abanwaraphael1526 ปีที่แล้ว

      @@dave-hollingworth please do and inform me here on what the problem could be..

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว

      @@abanwaraphael1526 They won't be able to give me any details of an individual customer, you'll have to contact Udemy support directly yourself with regards to specific purchasing issues: support.udemy.com/

  • @jimohumarfaruq767
    @jimohumarfaruq767 ปีที่แล้ว

    Please how can I get the password for my Gmail.
    I used my Gmail password and is not working

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว

      Please check the Google documentation for how to use their SMTP servers from a program

  • @nubianking7097
    @nubianking7097 9 หลายเดือนก่อน

    it didn't work.
    I am testing this code on a server not my own local wamp install and i am having trouble.
    i thought this tutorial would help but it did not

    • @dave-hollingworth
      @dave-hollingworth  9 หลายเดือนก่อน

      In what way didn't it work?

    • @nubianking7097
      @nubianking7097 9 หลายเดือนก่อน +1

      @@dave-hollingworth First of all thank you very much for your tutorials, it really is great information and delivered in a clear and concise manner.
      Secondly thank you for such a rapid response, wow!
      unfortunately all i can tell you at this point is the first time i ran your code it did not send the email, i checked my syntax and tried again to no avail.
      I originally made this comment hoping to learn why it did not work, but I have since gotten successful results using completely different code.
      so again thank you for your response

  • @shafeeqsharafi3731
    @shafeeqsharafi3731 2 หลายเดือนก่อน

    Sir can i do this work without hosting?

    • @dave-hollingworth
      @dave-hollingworth  2 หลายเดือนก่อน

      You need to be able to run PHP - the simplest way to do this is to install something like XAMPP and put the scripts in the root folder, then load them from there.

    • @shafeeqsharafi3731
      @shafeeqsharafi3731 หลายเดือนก่อน

      @@dave-hollingworth it works sir thank you...but i hosted the website in cpanel it not works why?

    • @shafeeqsharafi3731
      @shafeeqsharafi3731 หลายเดือนก่อน

      Message could not be sent. Mailer Error: SMTP Error: Could not authenticate.

    • @dave-hollingworth
      @dave-hollingworth  หลายเดือนก่อน

      @@shafeeqsharafi3731 In what way doesn't it work? Do you get any error messages?

    • @shafeeqsharafi3731
      @shafeeqsharafi3731 หลายเดือนก่อน

      @@dave-hollingworth Message could not be sent. Mailer Error: SMTP Error: Could not authenticate.

  • @PoshYoshii62
    @PoshYoshii62 ปีที่แล้ว

    how can i make a google admin account?

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว

      support.google.com/a/answer/172176?hl=en

    • @PoshYoshii62
      @PoshYoshii62 ปีที่แล้ว

      @@dave-hollingworth got it thanks

    • @PoshYoshii62
      @PoshYoshii62 ปีที่แล้ว

      @@dave-hollingworth actually tho do i need to have a company to log in

  • @nasedmarketingpublicidade
    @nasedmarketingpublicidade ปีที่แล้ว

    Hi

  • @harmonymwase3644
    @harmonymwase3644 ปีที่แล้ว

    less secure is not available

  • @abanwaraphael1526
    @abanwaraphael1526 ปีที่แล้ว +2

    SMS with php

  • @loopymomy2532
    @loopymomy2532 ปีที่แล้ว

    what you have failed to mention in this video is that the "from" portion in the email will use your email to send rather than the person's email to show up making the email portion useless. What you need to put in this video is how to have the "from" portion show up as the person's email. I can see that you are using a third party system to make this work.

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว

      You can't send an email from someone else's account. The email is sent from the account that's authorised on the server. What you can do though is add a "reply-to" address, which is what the email client will use as the recipient email address if you click "reply". Not all email clients support this though. For example: $mail->addReplyTo('info@example.com', 'Information');

    • @loopymomy2532
      @loopymomy2532 ปีที่แล้ว

      @@dave-hollingworth I did a different smtp to get the result. It works fine now. I noticed you were using a sandbox to make it work, I used sendinblue or smth like that

    • @anthonygeorges5828
      @anthonygeorges5828 ปีที่แล้ว

      @@loopymomy2532 How did you do that ?

    • @loopymomy2532
      @loopymomy2532 ปีที่แล้ว

      @@anthonygeorges5828 use a different stmp don't use Gmail.

  • @julietalejandro4989
    @julietalejandro4989 ปีที่แล้ว

    I'm just thinking maybe you could provide me a discount on your php for beginners 🤞🏻😅 or if you will have a sale soon, please let me know

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว

      Of course: www.udemy.com/course/php-for-beginners-/?couponCode=LPA_AUG_2022

  • @BalkanLeaksArchive
    @BalkanLeaksArchive ปีที่แล้ว

    how to send php mail without php mailer in plain php

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว +1

      Use the mail function: www.php.net/manual/en/function.mail.php

    • @BalkanLeaksArchive
      @BalkanLeaksArchive ปีที่แล้ว

      @@dave-hollingworth would that works on free web hostings

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว

      @@BalkanLeaksArchive Depends on the hosting, you'd have to check their documentation

    • @BalkanLeaksArchive
      @BalkanLeaksArchive ปีที่แล้ว

      @@dave-hollingworth i think they dont support mail send. Can i use some free smpt server and implemnt in my script

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว +1

      @@BalkanLeaksArchive Yes, you can use any free SMTP server. I would strongly suggest you use PHPMailer, it's just plain PHP code but wrapped up in a library. There's no reason it shouldn't work on your hosting, and it's so much easier than the mail() function.

  • @hirunawadasinghe
    @hirunawadasinghe ปีที่แล้ว +2

    This isn't helpful👎👎

  • @gabinetedeapoioasplataform3004
    @gabinetedeapoioasplataform3004 ปีที่แล้ว

    $mail->SMTPsecure = PHPMailer::ENCRYPTION_STARTTLS; - Syntax error: unexpected token '$mail'PHP(PHP2014) how can I solve?

  • @manasnikte
    @manasnikte ปีที่แล้ว +1

    i did exact same thing what you did, I am using hostinger web hosting and used that detail for smtp but send-email.php on browser it shows This page isn’t working localhost is currently unable to handle this request.

    • @manasnikte
      @manasnikte ปีที่แล้ว

      also tried hosting the files on web server
      but still didnt work

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว

      If you get a generic error message like that, there should be more error detail available in the error log - you should have access to this in the hostinger web panel. This should tell us exactly what the error is and where it's occurring

  • @adelsaidani7843
    @adelsaidani7843 ปีที่แล้ว

    Fatal error: Uncaught Error: Class "PHPMailer" not found in C:\xampp\htdocs\send-email.php:13 Stack trace: #0 {main} thrown in C:\xampp\htdocs\send-email.php

    • @dave-hollingworth
      @dave-hollingworth  ปีที่แล้ว

      Are you requiring the file that the class is defined in? Either using Composer's autoloader or requiring them directly.

  • @virtualdesigns4428
    @virtualdesigns4428 ปีที่แล้ว

    Estou com problemas em enviar formulario de contato de um site hospedado na locaweb. Você poderia me ajudar?