How to Set up an email server?

Source: Internet
Author: User
Tags call shell mx record
Such as question? In addition, I have another question: why can I send emails directly in linux? If this is the case, which PHP can directly execute the shell command when sending an email? Why do I need an email server? Such as question? In addition, I have another question: why can I send emails directly in linux? If this is the case, which PHP can directly execute the shell command when sending an email? Why do I need an email server?

Reply content:

Such as question? In addition, I have another question: why can I send emails directly in linux? If this is the case, which PHP can directly execute the shell command when sending an email? Why do I need an email server?

Simple emails, such as server alarms, can indeed be sent.
However, not every server has sendmail installed. In addition, to use anti-spam software, you may need to add email addresses to various whitelists.
I know so much and have not studied it in depth.

Not all servers allow php to execute shell commands.

No, it seems that it is a PHP mail function, and the local does not necessarily need an email server. I used to change the configuration file so that mail can directly connect to gmail, you only need to write the user name and password in the configuration file.
The built-in mail function is easy to use, but the premise is that the default mail server should be configured in php. ini.


  

See: http://php.net/manual/en/function.mail.php

It seems that you can directly use the SMTP class in the program to initialize the instance to connect to the server. Of course, this server can be either local or external.

$ Smtpserver = "smtp.126.com"; // SMTP server $ smtpserverport = 25; // SMTP server port $ smtpusermail = "xxxxxx@126.com "; // SMTP server user email $ smtpemailto = $ tempsendmail; // to whom to send $ smtpuser = "xxxxxx@126.com "; // SMTP server user account $ smtppass = "******"; // SMTP server user password $ mailsubject = "retrieve password "; // Email Subject $ mailbody = $ username. "Hello! "; // Mail content $ mailtype =" HTML "; // mail format (HTML/TXT), TXT is text mail $ smtp = new smtp ($ smtpserver, $ smtpserverport, true, $ smtpuser, $ smtppass); // here, true indicates that authentication is used; otherwise, authentication is not used. // $ smtp-> debug = TRUE; // whether to display the sent debugging information $ send = $ smtp-> sendmail ($ smtpemailto, $ smtpusermail, $ mailsubject, $ mailbody, $ mailtype );

Using CGI to call Shell can indeed achieve PHP's mail sending function. Mail transmission itself is a protocol that can communicate as long as it complies with the protocol. However, common email proxies process advertising emails, such as checking whether the Sending address and user name are consistent and whether domain names are common, the most important thing is to see the MX record corresponding to this domain name. Otherwise, most of your emails will be blocked as advertising emails or even more serious emails will cause bounce. As for the mail command you mentioned, sendmail is actually used to send emails, it is also an old mail client. It is not directly sent by using the mail command. You can try to uninstall sendmail and you will find a mail error.

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.