Php has recently learned how to use php to send emails. There are several questions to ask for leave. 1. what should I do if I want to send an email via my local machine? 2. if you use a virtual space, how can you determine that the space you are using can use php to send emails? 3. after confirming that the email sending condition is met, how can I use PHP to send emails? I am asking for advice at 100. please give me more details. thank you! ------ Solution -------------------- 1. if php sends an email
I recently learned how to use php to send emails. I have several questions to ask for leave.
1. what should I do if I want to send an email through the local machine?
2. if you use a virtual space, how can you determine that the space you are using can use php to send emails?
3. after confirming that the email sending condition is met, how can I use PHP to send emails?
I am asking for advice at 100. please give me more details. thank you!
------ Solution --------------------
1. what should I do if I want to send an email through the local machine?
You need to install the mta such as sendmail and postfix on the local machine. if you cannot use socket to call your own mailbox such as 163, sohu, and sina, google php smtp or phpmailer.
2. if you use a virtual space, how can you determine that the space you are using can use php to send emails?
Use the mail () function to send an email and test it.
3. after confirming that the email sending condition is met, how can I use PHP to send emails?
Mail ("test@test.com", "title", "body"), you can also see here more detailed http://php.chinaunix.net/manual/zh/function.mail.php
------ Solution --------------------
Learned
It is said that the mail function must be configured with the mail server on the local machine, otherwise it cannot be sent
I used socket for sending. I have never tried it.
------ Solution --------------------
It doesn't make much sense to support the mail () function. have the major post offices filtered out, not recognized, and not sent from the famous email server, avoiding too many spam mails,
After php uses socket to connect to an email server, it can use the mail server to send mail, just like simulating the e-mail software such as OE: sending a command to the other party, I want to send a mail, the content of my letter is ....... You can call NetEase before.
1. First, register a NetEase email address and use the user name and password, because he must authenticate that only his users can call him. And NetEase's smtp server ip address. The port is generally 25, which is usually set
2. Find a php socket mail class and search for it directly on Baidu.
------ Solution --------------------
Phpmail does not need to be repeated.
Search for sf.net.
------ Solution --------------------
The best test is to directly send it to the server...
------ Solution --------------------
Call method:
PHP code
$ Smtp_host = 'mail .163.com '; // sending server $ smtp_user = 'AAA @ 163.com'; // the email for sending authentication $ smtp_pass = '***'; // password $ smtp_port = 25; $ mail_format = 'html'; // or TXT for sending authentication. the format of the email is $ receiver er = 'BBB @ qq.com '; $ body = 'mail content'; $ sm = new smtp ($ smtp_host, $ smtp_user, $ smtp_pass, $ smtp_user, $ smtp_port ); if ($ sm-> sendmail ($ smtp_user, $ receiver, 'registration validating', $ body, $ mail_format) {echo 'failed to send email. '; exit ;}
------ Solution --------------------
Top !!! Test it!
Thank you for choosing the 15th floor.