Email configuration settings

Hi,

I am setting a new server and need the outgoing email working for contact form. Sendmail is configured to send emails through gmail smtp, and accordingly my gmail account is open for 'less secure devices'. I can send email from command line, and from another application DSpace, but somehow its not working from CollectiveAccess.

I have copied the email settings from https://github.com/collectiveaccess/pawtucket2/blob/master/app/helpers/post-setup.php and tries first adding in my pawtucket setup.php, assuming that global.conf will pull these settings from setup.php file, as it is pulling the DB configuration settings. No, it doesn't work. So I added the settings directly to my pawtucket app/conf/global.conf file. Again it doesn't work.

Also tried changing values for smtp_server, smtp_auth, smtp_username, smtp_password, smtp_ssl, smtp_port etc. directly in global.conf, but no success.

The interface says message "Message has been sent", but I receive no message. The mail log at /var/log/mail.log shows the following entries,

May 24 19:55:46 punlib sm-mta[444928]: 24OEPjM9444928: from=<kapila.amandeep@gmail.com>, size=877, class=0, nrcpts=1, msgid=<202205241425.24OEPjM9444928@mail.punlib.info>, proto=ESMTP, daemon=MTA-v4, relay=www.punlib.info [127.0.0.1]

May 24 19:55:46 punlib sm-mta[444930]: STARTTLS=client, relay=smtp.gmail.com., version=TLSv1.3, verify=FAIL, cipher=TLS_AES_256_GCM_SHA384, bits=256/256

May 24 19:55:47 punlib sm-mta[444930]: 24OEPjM9444928: to=<info@yourdomain.com>, delay=0000:01, xdelay=00:00:01, mailer=relay, pri=120877, relay=smtp.gmail.com. [172.253.115.109], dsn=2.0.0, stat=Sent (OK 1653402347 x7-20020ac80187000000b002f3fbf28826sm6163475qtf.23 - gsmtp)

Collective access sends emails directly through its own scripts, as in the case of DSpace, or relays through sendmail?

Also, how email should be configured for providence?

How to configure it? Kindly help.

Comments

  • CollectiveAccess can be configured to relay through sendmail but it set up by default to connect directly to a configured SMTP

    Most or all of these settings will need to be declared in setup.php:

    define("__CA_SMTP_SERVER__", 'smtp.sendgrid.net');
    define("__CA_SMTP_PORT__", 2525);
    define("__CA_SMTP_AUTH__", 'login');
    define("__CA_SMTP_USER__", 'apikey');
    define("__CA_SMTP_PASSWORD__", 'YOUR_PASSWORD_OR_APIKEY_HERE');
    define("__CA_SMTP_SSL__", "tls");
    

    The values in the example above are for SendGrid, which I've found is generally the least headache-inducing way to send emails from any application. You can of course use whatever SMTP server you wish but behavior will vary, with some servers burying your emails due to security policies. I would guess Gmail is classifying your outgoing message as spam due to the relay. Maybe try SendGrid or some other service and see if that works. If it does then you know the problem is with your public relay.

  • Hello,

    Thanks for the detailed response. The problem is solved with generous help at Chat service.

    Other settings were OK, the problem was the contact.conf file, in the theme configuration directory, where I needed to edit and replace the dummy email ID with my working gmail ID, which is why logs were showing the dummy email ID .i.e. info@yourdomain.com. The file doesn't seem to be pulling the email ID value from setup.php. Everything is working now.

    Gmail is definitely very restrictive about its services being used from different devices/servers, but they offer a workaround in the form of enabling "less secure apps" setting, that I have already configured right because I was already using the gmail smtp relay on the machine for other application and can already send emails. Another important aspect of the Gmail relay service is Gmail is known to revert the security settings to default if service not used for a long time, so problem may re occur, and will require to be fixed again.

    Thanks for your inputs. They made things more clearer.

    Regards,

    Aman

  • I am struggling to make my 'Contact' page working. I followed the above prescriptions several times. Initially I tried with my University's SMTP server settings which did not work. Then I tried with Yahoo mail's SMTP setting which also did not work. I keep on receiving the message "Your email could not be sent".

    I configured the setup.php files of CA and Pawtucket; the contact.conf file and the post-setup.php file.

    What else I can look into?

  • edited February 24

    Hi,

    Maybe your smtp server doen't need an authentification?

    Try to comment with # the following lines:

    define("__CA_SMTP_AUTH__", 'login');
    define("__CA_SMTP_USER__", 'apikey');
    define("__CA_SMTP_PASSWORD__", 'YOUR_PASSWORD_OR_APIKEY_HERE');
    


    Also, check if sending mail is allowed by your PHP configuration.

    For example, by executing this PHP script:

    <?php
    $to_user = "your@mail.com";
    $subject = "Test";
    $message = "Just a test";
    if ( mail($to_user, $subject, $message) == TRUE){
       echo "Mail OK\n";
    }
    else
    {
       echo "Mail error!\n";
    }
    ?>
    

    (In my case, I disabled the Contact page... I've just indicate an email contact in the About page.)

  • Thank you @darrigan for your response.

    I ran your PHP script and it returned "Mail error!". That means sending email is not allowed by my PHP configuration.

    As I am an absolute novice for PHP, could you suggest how I should proceed to fix my problem? My CA is installed on the localhost of Rocky Linux 8..

  • Wait... I'm checking that this code works for me, I'm not 100% sure! 😅

  • Okay, no problem. I can wait for your response.

Sign In or Register to comment.