PHP Mail Sending

Source: Internet
Author: User

PHP with Built-in mail () Send mail function, but more cumbersome; recommended to download a phpmailer online;

Generally there are two files, the left folder is containing class files, etc., the right is to send a configuration file

<?php
Require' phpmailer/class.phpmailer.php ';

$mail =New Phpmailer ();
$mail->issmtp ();
$mailCharSet =' Utf-8 ';

$mailHost =' Smtp.qq.com ';//Here you set the type of mailbox you want to choose to send

//If it isQqmailMust be set withSsland a port.
$mailSmtpsecure =' SSL ';//Settings useQs.Encryption Method Login Authentication
$mailPort =465;//Set upQs.ConnectionSmtpServer's remote server port number is optional465Or48V

$mailSmtpauth =TrueSmtpNeed to be authenticated this must beTrue
$mailUsername =‘Hao‘;//Here you set the user name of the mailbox you choose
$mailPassword =' 123456789 ';//QQ mailbox words,set the password for your chosen mailbox here,authorization Code; If it's another mailbox, it's the mailbox password.

$mailfrom =' [email protected] ';//Email address for sending mail
$mailFromName =' Jacko ';//Send the name of the message

$mailSubject =‘Test‘;//This looks like a headline.
$mailBody =‘Hello, this is a test mail.‘;//This seems to be the content

$mail->addaddress ("[Email protected]",$name ="Xiao ming");//The first one is the address of the recipient's mailbox, and the second is the recipient's name.

$result = $mail->send ();

if ($result) {
echo ' send success ';
}else{
echo ' send failed ';
}

?>


General Phpmailer files can be found from the Internet, we download the main according to their own mailbox type to modify the Send file configuration, < Span style= "font-weight:bold;" > above notes Red is sure to go to modify their own , General 163 of the mailbox is the host there is write smtp.163.com, if it is QQ mailbox as above, there are to set up SSL and port, so as to successfully send out;
If you do not send out, there are the following reasons:
(1) The mailbox does not have permission to open the SMTP, this you have to log in your own mailbox settings open, generally this can be sent basically!

(2) or your SSL is not turned on, this need to php.ini inside modify;

This phpemailer probably need to configure these things, as for the PHP comes with the mail (), I am also in the study, experienced Daniel, please pointing!

PHP Mail Sending

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.