Solet's talkaboutsending e maildirectlyfrom a PHPscript.
SooneofthenicethingswithPHPisthatthereisanactualfunctioncalledthemalefunctionthatallowsyoutosendemaildirectlyfrom a PHPscriptsoyoucancreate a variableforthetwo.
A variableforthesubjectofvariableforthemessagesoonandsoforth.
Sothisissomethingtorememberwiththemalefunctionis, itdoeshavetohavethatlocalemailserver, and I havetosayfromexperience, I preferpreferrednothavingtoinstallemailservers.
Serviceissuchassendinggridandactuallyuse a male A p I togetnextto a centigradeinfrastructure, sothat's onewayyoucandoit.
Butifallyou'redoingisyou'relookingfor a verysimplewayjusttobeabletosendoutemailnotificationsbysimplyusingthemalefunctionbuiltintoPHP.
Youcandothatandagain, ifyou'realreadyon a sharedpostingsserver, thenyoudon't havetoworryaboutAPeyesoranyofthattypeofstuff.
Sowiththat, let's gooverthecomputer, showyouhowthisbasicmalefunctionworks, and I thinkyou'llbeprettyimpressed.
It's a it's a prettycoollittlefunction.
Sothisisjust a simplescriptthat I createdcalledmail, notPHP.
Nowitisimportanttounderstandwiththisscript, notonlyam I usingthescripttoactuallysendanemail, but I didput a littletroubleshootingroutinewithinthescriptjusttomakesurethisscriptactuallyraninhisupdating.
So I have a littlescriptofranwiththevalueofthevariabletimeinhere, andwhatthisisgoingtodoisaftertheemailascent, thiswillsimplyprintonthescreenthatthescriptactuallyranatthespecificcomputertime.
So I dothistypeofthingagainis a troubleshootingroutine.
Justthefair.
Verifythatthescriptisrunning.
Soifittakes a littlewhiletogettheemail, I knowit's justdelayedontheInternet.
It's not a problemwiththescriptitself, butanyways, ifwetake a lookatthisagain, asalways, weopenwith a PHPtag.
Inorderforthemalescripttorun, allyouneedistoallyouneed a subject, andallyouneedismessageyoudon't actuallyneedfromfromiskindofanaddonthatyouputonlater.
Soifyousendanemailusingjusttosubject a message, thefrom, well, actuallyjustbeyourserveraddress.
Sothatcouldbeonething.
From a securitystandpoint, ifyoudon't put a frominthere, isthatitwill, itwilltellthepersonthatyouemail, basicallythefromthatwillgetautofilledinwiththeserveraddressthattheemailscomingfrom.
Sothat's onethingyouhavetothinkaboutfrom a securitystandpoint.
Ifyoudon't, ifyoudon't actuallyhardcodedfromandyoumighthaveissueswithwithspamfiltersblockingitsoyoucansendthese e mailmessageswithHalladayfromagainifyoudon't care, especiallyifthisislikeaninternalemail.
Youmaynotcareaboutthefromah, butfromisniceagainfrom a securitystandpointfromthisantispamstandpointandevenoneofthecoolpartsyoucandioisforthefromYoucanactuallyevenhavethefrombeingnotreallyemailaddressandthenusedGmailfilterstodumpdumplikenotificationsinto a specificinto a specificfolder.
So, youknow, writeanythingfromlogsatfailuredotcomgoesintothisspecificfoldersoyoucoulddosomeinterestingthingstherewithwithusingfrom, butbasicallyhere, ifyouwanttodoitfromyoufromwhereyou'regoingtodoisyou'regoingtoaddheaders.
Sothere's a lotofdifferentthingsyoucanaddwiththeheaders.
Theotherthingtothinkaboutisifyou'rein a corporateworld, soyouhave a reallyantispamsolution.
Tobeclear, ifyouhave a realantispamsolution, thiscrapshouldbeblockedreallyquick, becausebasically, thisiskindofthisiskindoflike a phishingattack, right?
Ifyoutake a lookatthis, yougobacktomail.
I mean, again, thethinglikefrom I coulddo a TSHareatbankofjapandotcom.
I coulddolikethat's justthat's justcoatedinthere.
That's this.
Soyouunderstand.
I'm literallyrightnowshowingyouhow a fishingorspearphishingattackactuallyworks.
Andsothere's somewaystopreventthattypeofthing.
Andsothat's what a corporateemailaccountshouldblock.
Butyeah, uh, andsoagain.
Sonowdownhere, ifyoutake a look.
Yousee, we'venowgotaneight e mails.
Now, I don't wanttoshowyou, uh, myparticularemailbox.
That's why I wouldsuggestthatyouuse a sharedhostingplanatleasttobeginwithagainasyourstartingwith P H B.
Pay a coupleofbucksforsharedhostingplanasyouunderstandthingsmorethanyoucandoyourownserver, becausethisistheproblemthatyourunintowith a lotoffolksistheytrytobuildtheirownserverfromdayoneandthenimagine.
Andthat's onereasontowhy a lotofpeople, whentheydostarttocode, theydecidetousesomethinglikesendgrids.
AP I.
Sosendgridisbasicallyan e mailinfrastructureforsendingoutmassiveemails.
Oneofthereasonspeopledecidetouse a thesendgrid a p I, andevenpayfortheSenateGreat a p I versususingthis, althoughthisiscompletelyfreeissendgridverifiestheiremailserversarenotonblacklists.
Theyverifyyouknow, thingstomakesurethatit's mostlikelythat e mailswillactuallygothrough.