The Godaddy space, PHP, and webmail form use the Godaddy Linux host. The Windows host should be similar. I did not try it.
The first method is to use the mail () function provided by php to send emails.
File Organization: place the 123.html and send. php files in the same directory.
123. html
Send. php
$ To = "lasercoder@foxmail.com ";
$ Subject = "topic ";
$ Message = "Hello! ". $ _ POST [" name "].", This is a simple email message .";
$ From = "coder ";
$ Headers = "From: $ from ";
If (mail ($ to, $ subject, $ message, $ headers ))
Echo "Mail sent .";
Else echo "Mail fail .";
?>
Method 2: Use the phpmailer open-source class
Put 123.html and send. php in the same directory, download phpmailer, name it phpmailer, and put it in the same directory.
Godaddy gives away enterprise mail and adds an email account in the control panel to facilitate entering the SMTP email account and password below.
123. html
Send. php
Header ('content-Type: text/html; Charset = utf-8 ');
Require "phpmailer/class. phpmailer. php ";
$ Mail = new PHPMailer;
$ Mail-> isSMTP (); // you can specify SMTP for an email.
$ Mail-> Host = 'mail .site.com '; // email server address
$ Mail-> SMTPAuth = true; // enable SMTP Authentication
$ Mail-> CharSet = "UTF-8"; // Set the email encoding
$ Mail-> setLanguage ('zh _ cn'); // sets the Chinese prompt for an error.
$ Mail-> Username = 'admin @ site.com '; // SMTP Username, that is, the personal email address
$ Mail-> Password = '000000'; // SMTP Password, that is, the personal email Password
$ Mail-> SMTPSecure = 'tls '; // Set to enable encryption. note: The php_openssl module must be enabled.
$ Mail-> Priority = 3; // Set the mail Priority to 1: high, 3: Normal (default), 5: low
$ Mail-> From = 'someone @ someone.com '; // The sender's email address.
$ Mail-> FromName = 'sender name'; // sender name
$ Mail-> addAddress ('lasercoder @ foxmail.com '); // add recipient
$ Mail-> ConfirmReadingTo = 'someone @ someone.com '; // add the Send receipt email address, that is, when the recipient opens the email, it will ask whether a receipt has occurred
$ Mail-> addBCC ('Someone @ someone.com '); // add a bcc. the Mail Header does not display the BCC information.
$ Mail-> WordWrap = 50; // set to automatically wrap 50 characters
$ Mail-> addAttachment ('/tmp/image.jpg', 'One pic '); // add multiple attachments
$ Mail-> isHTML (true); // you can specify the email format as HTML.
$ Mail-> Subject = 'here is the topic ';
$ Mail-> Body = 'This is the HTML information body
In bold!. Time :';
$ Mail-> AltBody = 'This is the subject in plain text for non-HTML mail clients ';
If (! $ Mail-> send ()){
Echo 'message cocould not be sent .';
Echo 'mailer Error: '. $ mail-> ErrorInfo;
Exit;
}
Echo 'Message has been sent ';
?>