PHP Mail


PHP should be well organized in the php.ini file with details of how your system sends you an email. Open the available php.ini file / etc / directory and find the header section [mail function].

Windows users should ensure that two directions are provided. The first one is called SMTP which describes your server's email address. The second one is called sendmail_from which describes your email address.

Windows configuration should look like this -

[mail activity]
; For Win32 only.
SMTP = smtp.secureserver.net
; For win32 only
sendmail_from = webmaster@tutorialspoint.com< br >		

Linux users simply need PHP to know the location of their sendmail system. The method and any desired changes should be specified in the sendmail_path command.

Linux configuration should look like this -

[mail activity]
; For Win32 only.
SMTP =

; For win32 only
sendmail_from =

; Unix only
sendmail_path = / usr / sbin / sendmail -t -i
Now you're ready to go -

Sending clear text email

PHP uses mail () functionality to send email. This function requires three authorized arguments that define the recipient's email address, the subject of the message and the message itself and there are two other principles to choose from.

email (to, subject, message, topics, parameters);

<?php $to = "knowledge 2life@gmail.com";//change receiver address $subject = "This is subject"; $message = "This is a simple email message."; $header = "From:knowledge@gmail.com \r\n"; $header .= "MIME-Version: 1.0 \r\n"; $header .= "Content-type: text/html;charset=UTF-8 \r\n"; $result = mail ($to,$subject,$message,$header); if( $result == true ){ echo "Message sent."; }else{ echo "Sorry, Email Failed."; } ?>