Skip to main content
Topic: Cannot Send Mail (Read 3160 times) previous topic - next topic

Cannot Send Mail

I have developed a project using phprad 2.7.3.
I have also setup a server on Hostinger and have used it previously to send emails using custom code (not phprad).

I want to send an email once a new user is added.
These are the steps that I have covered :

1. I Configured the Email Settings on my project : sender name, sender email, SMTP Host Server, SMTP Server Port, SMTP Username and password.

2. On PageEvents, I clicked on Users ->  Add  ->  AfterAdd.

3. Here, I posted the following code :

         $mailtitle      = "New User Added";
         $mailbody       = "Mail body. Support html content";
         $receiver_email = DEFAULT_EMAIL;
         $mailer         = new Mailer;
         $mailer->send_mail($receiver_email, $mailtitle, $mailbody);

4. I tried running the project on localhost. The page runs fine, but I donot receive any email.
5. I even tried running the project on my Hostinger's server. Again, no email received.

Kindly suggest what can I do :)

Re: Cannot Send Mail

Reply #1
@junaid97‍ hi, it is advisable to use the default mailing, by configuring Sender Name and Sender Email only. but if you want to connect using SMTP, then you have to provide the information needed on the To Use SMTP Server section of the Project Email Settings Configuration in Project settings, and also take an extra step of manually editing the Mailer.php file line 8 and line 18 providing the type of security and port your SMTP server is using. And also make sure to publish your project to Production, thanks.

Re: Cannot Send Mail

Reply #2
1) I set the Sender Name and Sender Email in the Config.php file.

2) I also set the type of security and port my server is using in Mailer.php file.

3) I set the project in Production mode in the config.php file.

4) Once a user is added, the following code runs :

            $mailtitle      = "New User Added";
            $mailbody       = "Mail body. Support html content";
            $receiver_email = DEFAULT_EMAIL;
            $mailer         = new Mailer;
            $mailer->send_mail($receiver_email, $mailtitle, $mailbody);






Yet, I do not receive any email. Kindly help.

Re: Cannot Send Mail

Reply #3
@junaid97‍ please try doing a password reset on your project to see if you receive an email. If you do, try configuring Mail Action Settings in the Add Page Properties. If you don't, please make sure your mail server configuration is correct, and mails are not being sent to your spam box, thanks.

Re: Cannot Send Mail

Reply #4
1) When I send my email address on Password Reset Page, the page displays that the mail has been successfully sent. Even though I do not receive any email on said address.

2) I have tried, multiple times, configuring the Mail Settings. This is what I put :

// Email Configuration Default Settings
define("USE_SMTP",true);
define("SMTP_USERNAME", "MYUSERNAME");
define("SMTP_PASSWORD", "MYPASSWORD");
define("SMTP_HOST", "smtp.hostinger.in");
define("SMTP_PORT", "587");

I have used the same configuration and have successfully sent emails using custom code on smaller projects.


3) I even manually changed the Port Setting in Mailer.php; I mentioned this previously.

I am lost.


 

Re: Cannot Send Mail

Reply #6
i have the same issue i couldn’t connect to smtp via codes.

Can you tell me how did you resolve the issue ?