PHP Mail Function Disabled - How to Setup SMTP to Send Mail for Contact Forms


There are so many ways to send email using php. The two main ways to do this is either using PHPMail() or SMTP. PHPMail() is open and used by trojans and viruses. Most clients have infected files which just send mails using PHPMail(), because it doesn't authenticate. It doesn't check if the email being sent is actually coming from the domain and this puts a lot of strain on the mail server, making legitimate mails wait in queue for a long time.

SMTP isn't open and the email must be authenticated.... a real email address and password must be written into your code and must be verified by the mail server before the email is sent. This makes the email legitimate.

If you already have a script using PHPMail() function it is very simple to change it to SMTP, you just need to change like 5 lines of your code and add an email address and password (already created in cpanel) into the code, and it will send emails just fine.

If you are using a cms software like wordpress or joomla please use the smtp plugins available for these softwares.

For Joomla:

At the backend of joomla, under global configuration --> Server --> Mail Settings -->

Mailer: SMTP
SMTP Port: 25
SMTP Authetication: Yes
SMTP Security: None
SMTP Username: email address created in cpanel
SMTP Password: password for your email address
SMTP Host: localhost


For Wordpress:

1. http://wordpress.org/plugins/easy-wp-smtp/(By wpecommerce)

2. http://wordpress.org/extend/plugins/contact-form-7/


Edit General Settings for Easy WP SMTP
From Email Address: your email address i.e info@mydomain.com
From Name: a name to give your email address i.e Company Name
SMTP Host: mail.yourdomain.com
Type of Encription: None
SMTP Port: 25
SMTP Authentication: Yes
SMTP username: Your email address ( same as the From Email Address)
SMTP Password: Password of the email address above


For Developers:

The PEAR library also has a built-in Mail class for sending e-mails, including e-mails over SMTP authentication with an already-existing e-mail account. Here's an example:

$mail->Host = 'mail.' . $domain; //Set the SMTP server to send through
$mail->SMTPAuth = true; //Enable SMTP authentication
$mail->Username = $senderEmail; //SMTP username
$mail->Password = $senderPass; //SMTP password
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; //Enable implicit TLS
encryption
$mail->Port = 587; //TCP port to connect to; use ENCRYPTION_SMTPS= 465 or
ENCRYPTION_STARTTLS= 587 if you have set `SMTPSecure =
PHPMailer::ENCRYPTION_SMTPS`
//Recipients


the above works well for does use Using PHPMailer 6.5.3 

 

If you are unable to set this up or still having issues, Please contact our support as soon as possible and we will fix it for you

  • 251 Users Found This Useful
Was this answer helpful?

Related Articles

How to Setup Your Email on Your Phone

You can follow the steps below to setup your custom email on your phone/device using the Gmail...

How to Create Email Accounts in cPanel

The following steps describe how you can create a customised email in cPanel with your domain...