Beginner Php,mail () e-mail questions, want to consult

Source: Internet
Author: User
I am currently learning the basic grammar in W3school and see the case of sending email

$to = "someone@example.com";
$subject = "Test mail";
$message = "hello! A simple email message. ";
$from = "someonelse@example.com";
$headers = "From: $from";
Mail ($to, $subject, $message, $headers);
echo "Mail Sent.";

?>
Test cannot send mail
Would like to consult the PHP e-mail Just a few words of simple code can be achieved? Do not need the sender's account password, and other settings?


Reply to discussion (solution)

Please refer to the video tutorial Http://pan.baidu.com/s/1rIJeU or http://www.zixue.it/portal.php?mod=list&catid=11 using PHP Mailer to send an email.

The Mail function can only send mail using a sender server that does not require user authentication
If you use a sender server that does not have user authentication, you also need to configure it in php.ini to use the Mail function

Require_once (' email.class.php ');
//##########################################

$smtpserver = "smtp.163.com";//SMTP server
$smtpserverport =25;//SMTP Server Port
$smtpusermail = "Your @163.com";//smtp the user mailbox of the server
$smtpemailto = $email;//Send To whom
$smtpuser = "name"; user account for//SMTP server
$smtppass = "ADDFGFDG"; user password for//SMTP server

$mailsubject = "Mail subject";//Message subject
$mailbody = "Message content Mail content mail Content"//message content
$mailtype = "HTML";//Message Format (html/txt), TXT as text mail
$SMTP = new SMTP ($smtpserver, $smtpserverport, True, $smtpuser, $smtppass);//A true in this indicates that authentication is used, otherwise no authentication is used.
$SMTP->debug = false;//whether to display debug information sent
$smtp->sendmail ($smtpemailto, $smtpusermail, $mailsubject, $mailbody, $mailtype);
?>

Need certification, or use Phpmailer bar, simple configuration a few can be.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.