Difference between revisions of "PHP-and-MySQL/C4/Sending-Email-Part-3/English-timed"
From Script | Spoken-Tutorial
Sandhya.np14 (Talk | contribs) |
|||
(2 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
|- | |- | ||
|00:00 | |00:00 | ||
− | |Welcome back. How do we fix this "' | + | |Welcome back. How do we fix this "'Sendmail_from' not set in php dot ini" error? |
|- | |- | ||
|00:11 | |00:11 | ||
Line 16: | Line 16: | ||
|- | |- | ||
|00:29 | |00:29 | ||
− | |We need to send to specific headers. | + | |We need to send to specific '''headers'''. |
|- | |- | ||
|00:32 | |00:32 | ||
− | |So here we create a "headers" variable which is not equal to something like "me @me.com" | + | |So, here we create a "$headers" variable which is not equal to something like "me @me.com". |
|- | |- | ||
|00:43 | |00:43 | ||
− | |What we need to do is work with the | + | |What we need to do is, work with the standardized '''mail header''' and that is "From:" and a colon not semi colon and then we say for example "PHP Academy". |
|- | |- | ||
|00:54 | |00:54 | ||
− | |Or you could say something like "admin @ | + | |Or you could say something like "admin @PHP Academy" and add ".com", if you like. |
|- | |- | ||
|01:02 | |01:02 | ||
Line 34: | Line 34: | ||
|- | |- | ||
|01:11 | |01:11 | ||
− | | | + | |And now, inside our mail we need to add another parameter which is "headers". |
|- | |- | ||
|01:18 | |01:18 | ||
− | |And now we come here and you can type "Alex" and here "This is a test!" | + | |And now we come here and you can type "Alex" and here "This is a test!". |
|- | |- | ||
|01:24 | |01:24 | ||
Line 46: | Line 46: | ||
|- | |- | ||
|01:33 | |01:33 | ||
− | |If you don't want to run a mail server on your computer, google for at mail free mail server and this will install a mail server on your computer just like we are doing now running on a local host. | + | |If you don't want to run a mail server on your computer, google for at mail free mail server and this will install a '''mail server''' on your computer just like we are doing now running on a '''local host'''. |
|- | |- | ||
|01:46 | |01:46 | ||
− | | | + | |So, you will have a '''SMTP mail server''' running under '''local host'''. |
|- | |- | ||
|01:54 | |01:54 | ||
− | |Now as I don't have a mail server, I will use my university email system which is the DNS or the "Domain Name Server" of my university email | + | |Now, as I don't have a '''mail server''', I will use my university email system which is the DNS or the "Domain Name Server" of my university email. |
|- | |- | ||
|02:06 | |02:06 | ||
Line 70: | Line 70: | ||
|- | |- | ||
|02:41 | |02:41 | ||
− | |And the best way to do this is to come here and setup our variables | + | |And the best way to do this is to come here and setup our variables. |
|- | |- | ||
|02:46 | |02:46 | ||
− | | | + | |Okay, we need 2, set SMTP in "php dot ini" |
|- | |- | ||
|02:59 | |02:59 | ||
− | | | + | |and instead of opening up my "php dot ini" file, I'll just use the "ini_set()" function |
|- | |- | ||
|03:05 | |03:05 | ||
− | | | + | |and the variable name is "SMTP". |
|- | |- | ||
|03:12 | |03:12 | ||
− | |So we are editing this line inside our "php dot ini" file. | + | |So, we are editing this line inside our "php dot ini" file. |
|- | |- | ||
|03:16 | |03:16 | ||
− | |And I type the | + | |And I type the "mailhost" in there as the value. |
|- | |- | ||
|03:20 | |03:20 | ||
− | |Here we just say echo " | + | |Here we just say '''echo''' "get_ini()" which gets a specific value. |
|- | |- | ||
|03:25 | |03:25 | ||
− | |Next I'll say SMTP and that can just kill the script there. | + | |Next I'll say "SMTP" and that can just kill the script there. |
|- | |- | ||
|03:30 | |03:30 | ||
− | |So we can see how this works. | + | |So, we can see how this works. |
|- | |- | ||
|03:32 | |03:32 | ||
− | |So if I say "Alex" and then "Test" and click on "Send me this". | + | |So, if I say "Alex" and then "Test" and click on "Send me this". |
|- | |- | ||
|03:40 | |03:40 | ||
− | |Oh! Sorry I have typed this completely wrong. Big mistake. That is " | + | |Oh! Sorry I have typed this completely wrong. Big mistake. That is "ini_get()" and let's refresh that. |
|- | |- | ||
|03:52 | |03:52 | ||
− | |Okay we are basically setting our "SMTP" inside our "ini" file to "mail host dot shef dot ac dot uk". | + | |Okay, we are basically setting our "SMTP" inside our "ini" file to "mail host dot shef dot ac dot uk". |
|- | |- | ||
|03:59 | |03:59 | ||
− | |And then we will echo out the value of this. | + | |And then we will '''echo''' out the value of this. |
|- | |- | ||
|04:03 | |04:03 | ||
− | |So this just tells me that that is set to "mail host dot shef dot ac dot uk". | + | |So, this just tells me that- that is set to "mail host dot shef dot ac dot uk". |
|- | |- | ||
|04:10 | |04:10 | ||
− | |Presuming this mail host server or DNS server works, then the rest of the code will work. | + | |Presuming this '''mail host server''' or DNS server works, then the rest of the code will work. |
|- | |- | ||
|04:17 | |04:17 | ||
− | |After sending our mail I'll just kill the page. | + | |After sending our mail, I'll just kill the page. |
|- | |- | ||
|04:24 | |04:24 | ||
− | |Um.... no I won't . I'll just kill the page. | + | |Um.... no I won't. I'll just kill the page. |
|- | |- | ||
|04:28 | |04:28 | ||
− | | | + | |Let's go back and say "Alex" and "This is a test". |
|- | |- | ||
|04:36 | |04:36 | ||
− | |Just checking that everything is okay. We've got my "to", my "subject", my "headers" saying "From:admin@phpacademy.com". | + | |Just checking that everything is okay. We've got my "$to", my "$subject", my "$headers" saying "From:admin@phpacademy.com". |
|- | |- | ||
|04:45 | |04:45 | ||
− | |And our body in here and we are executing our mail function. | + | |And our '''$body''' in here and we are executing our '''mail()''' function. |
|- | |- | ||
|04:51 | |04:51 | ||
− | |So when I click "Send me this", nothing happens. We've got no errors so we can presume that everything has worked. | + | |So, when I click "Send me this", nothing happens. We've got no errors, so we can presume that everything has worked. |
|- | |- | ||
|04:58 | |04:58 | ||
− | |If I come into my | + | |If I come into my Hotmail or my email and click on my INBOX, you can see that we've now got a mail from "admin @ phpacademy dot com". |
|- | |- | ||
|05:09 | |05:09 | ||
Line 142: | Line 142: | ||
|- | |- | ||
|05:22 | |05:22 | ||
− | |You can put this as from Alex or from phpacademy. | + | |You can put this as from Alex or from 'phpacademy'. |
|- | |- | ||
|05:27 | |05:27 | ||
− | |And then we have "This is an email from Alex" which is the name we gave inside the form here. | + | |And then we have "This is an email from Alex" which is the name we gave inside the '''form''' here. |
|- | |- | ||
|05:35 | |05:35 | ||
− | |And then we have 2 line breaks which are present | + | |And then we have 2 line-breaks which are present, 1 and 2. |
|- | |- | ||
|05:40 | |05:40 | ||
Line 154: | Line 154: | ||
|- | |- | ||
|05:46 | |05:46 | ||
− | |So that's a mail function by using my university's DNS mail server. | + | |So, that's a '''mail''' function by using my university's DNS mail server. |
|- | |- | ||
|05:50 | |05:50 | ||
Line 163: | Line 163: | ||
|- | |- | ||
|06:00 | |06:00 | ||
− | |So if this doesn't work for you watch that tutorial or just drop me an email or contact me through my | + | |So, if this doesn't work for you watch that tutorial or just drop me an email or contact me through my you-tube. |
|- | |- | ||
|06:09 | |06:09 | ||
− | |OK so I hope that was useful to a lot of people. | + | |OK, so I hope that was useful to a lot of people. |
|- | |- | ||
|06:13 | |06:13 | ||
Line 172: | Line 172: | ||
|- | |- | ||
|06:15 | |06:15 | ||
− | |Alright, thanks for watching. This is Evan Varkey dubbing for the Spoken Tutorial Project. Bye bye. | + | |Alright, thanks for watching. This is Evan Varkey, dubbing for the Spoken Tutorial Project. Bye bye. |
Latest revision as of 11:46, 6 June 2015
Time | Narration |
00:00 | Welcome back. How do we fix this "'Sendmail_from' not set in php dot ini" error? |
00:11 | We haven't determined who the email is from. |
00:18 | We need to do this in order to send the email. |
00:23 | We won't use something like a "from" parameter here. |
00:29 | We need to send to specific headers. |
00:32 | So, here we create a "$headers" variable which is not equal to something like "me @me.com". |
00:43 | What we need to do is, work with the standardized mail header and that is "From:" and a colon not semi colon and then we say for example "PHP Academy". |
00:54 | Or you could say something like "admin @PHP Academy" and add ".com", if you like. |
01:02 | I don't actually have that domain name but we'll just keep it as that. |
01:08 | So "From: admin @phpacademy.com". |
01:11 | And now, inside our mail we need to add another parameter which is "headers". |
01:18 | And now we come here and you can type "Alex" and here "This is a test!". |
01:24 | Click on "Send me this" and we face another error. |
01:27 | Now I am not actually running a mail server on my computer. |
01:33 | If you don't want to run a mail server on your computer, google for at mail free mail server and this will install a mail server on your computer just like we are doing now running on a local host. |
01:46 | So, you will have a SMTP mail server running under local host. |
01:54 | Now, as I don't have a mail server, I will use my university email system which is the DNS or the "Domain Name Server" of my university email. |
02:06 | That's the way my email is sent through my university. |
02:11 | If you know a specific DNS Server, if you have a domain name already, if you have a website you will know it or you will be able to find it, at least. |
02:22 | You will be able to send an email through that. |
02:27 | I know that my university email DNS server is "mailhost dot shef dot ac dot uk" because I'm in Sheffield university. |
02:36 | So I need to incorporate this into my "php dot ini". |
02:41 | And the best way to do this is to come here and setup our variables. |
02:46 | Okay, we need 2, set SMTP in "php dot ini" |
02:59 | and instead of opening up my "php dot ini" file, I'll just use the "ini_set()" function |
03:05 | and the variable name is "SMTP". |
03:12 | So, we are editing this line inside our "php dot ini" file. |
03:16 | And I type the "mailhost" in there as the value. |
03:20 | Here we just say echo "get_ini()" which gets a specific value. |
03:25 | Next I'll say "SMTP" and that can just kill the script there. |
03:30 | So, we can see how this works. |
03:32 | So, if I say "Alex" and then "Test" and click on "Send me this". |
03:40 | Oh! Sorry I have typed this completely wrong. Big mistake. That is "ini_get()" and let's refresh that. |
03:52 | Okay, we are basically setting our "SMTP" inside our "ini" file to "mail host dot shef dot ac dot uk". |
03:59 | And then we will echo out the value of this. |
04:03 | So, this just tells me that- that is set to "mail host dot shef dot ac dot uk". |
04:10 | Presuming this mail host server or DNS server works, then the rest of the code will work. |
04:17 | After sending our mail, I'll just kill the page. |
04:24 | Um.... no I won't. I'll just kill the page. |
04:28 | Let's go back and say "Alex" and "This is a test". |
04:36 | Just checking that everything is okay. We've got my "$to", my "$subject", my "$headers" saying "From:admin@phpacademy.com". |
04:45 | And our $body in here and we are executing our mail() function. |
04:51 | So, when I click "Send me this", nothing happens. We've got no errors, so we can presume that everything has worked. |
04:58 | If I come into my Hotmail or my email and click on my INBOX, you can see that we've now got a mail from "admin @ phpacademy dot com". |
05:09 | If we click on it, we have "Email from PHPAcademy" as our subject line that we had set here. |
05:17 | And we have the email address that I specified from. |
05:22 | You can put this as from Alex or from 'phpacademy'. |
05:27 | And then we have "This is an email from Alex" which is the name we gave inside the form here. |
05:35 | And then we have 2 line-breaks which are present, 1 and 2. |
05:40 | And "This is a test" which is the text I put in there. |
05:46 | So, that's a mail function by using my university's DNS mail server. |
05:50 | Your INSP will have a DNS mail server. |
05:55 | It may require authentication on which I will be completing the tutorial soon. |
06:00 | So, if this doesn't work for you watch that tutorial or just drop me an email or contact me through my you-tube. |
06:09 | OK, so I hope that was useful to a lot of people. |
06:13 | Please subscribe if you haven't already. |
06:15 | Alright, thanks for watching. This is Evan Varkey, dubbing for the Spoken Tutorial Project. Bye bye. |