I have hosted my website on Plesk Hosting and was working on submitting the contact form.
Installed PHP Mailer using composer.
First
I tried to send email using Gmail SMPT server
it worked fine
Second
I tried to send email using my webhosting SMTP Server
it is not working for me
$mail->Host = 'webmail.abc.in'; //host
$mail->SMTPAuth = false;
$mail->Username = '******@abc.in';
$mail->Password = '*******';
$mail->SMTPSecure = 'tls';
$mail->Port = 25;
I tested the SMPT server using SMTPER . it could send email using same credentials.
i dont know where the issue is..
is there any other library other then phpmailer??
3
Answers
As simple as that, I think.
You said you have tested the credentials on SMTPer,
I’m sure you checked the “Use authentication” checkbox.
Maybe you thought you could make it false because you are not using SSL,
But this is about user authentication, not about encrypted communication.
This is a example of of code I’m using with gmail. Tested it with webhosting SMTP and worked as well.
Are you using a Shared Hosting with Plesk? If yes, then this can probably be a port block issue (exact reason you will get only in the maillog). Looking at your code, I can see that in case of your local SMTP testing you are using port 25 while in case of Gmail it’s 465.
By default, most of the shared hosting providers block the outgoing SMTP connection on port 25. This is done in order to protect the network and infrastructure from Spamming. If this is the case, then you need to contact their support to unblock the port or use some port free mode of email sending. Means instead of connecting over SMTP, connect over HTTP API for sending emails.