How to send email from a script on your web site Print

  • 19

There several different methods to send email from a script on a website. However many of these methods while appropriate on dedicated and virtual web servers, pose unacceptable security risks on a shared web server. For the same reasons we do not generally allow Perl and .cgi scripts on our shared servers, we recommend that you write your scripts in PHP. You may also use a high quality module, written in PHP, like PHPMailer.

To protect both you and the other users on our shared web servers, we insist that you submit emails to a registered SMTP server on which you have an account. You will need to configure your script to act as a SMTP client. The following configuration items should be helpful:

  • Hostname: the Fully Qualified Host Name of your SMTP server for example, ‘mail.abhost.net’. Do not use ‘localhost’.

  • Port number: only port 587 is allowed through our firewall. Port 25 is blocked and will not work.

  • Security: select TLS if not available then use SSL.

The above information should allow you to pass our firewall and connect to your SMTP server. Your SMTP server will also have requirements to meet before it accepts your email for delivery:

  • Each email must authenticate itself with:

    • Account name: this is most often your full email address.

    • Password: make it a strong and unique password. DO NOT use the same password as any other email account.

  • The ‘from’, ‘sender’ or ‘mail from’ headers may have to match your account.

 

WARNING:  other configurations may appear to work, but sooner or later you will have problems. Email sent using PHP mail() is rate limited to a very small number of emails per hour, if another user starts sending emails, your emails may be blocked. When you send email with a SMTP account, the decision on whether to accept the email is based on the reputation of your SMTP account. When you send email with PHP mail(), the decision on whether to accept the email is based on the IP address of the shared server. You have no control over the reputation of a shared server; it will vary from hour to hour.


Was this answer helpful?

« Back

Powered by WHMCompleteSolution