Extendy / SmartyURL

SmartyURL is a PHP-based web application for Smart URL management, Sharing, shortening, and analytics, featuring smart redirects.
https://docs.smartyurl.extendy.net/
MIT License
12 stars 2 forks source link

SmartyURL has error sending email in live env. #35

Closed mshannaq closed 9 months ago

mshannaq commented 11 months ago

SmartyURL has error sending email in live env. testing for login with smart link in shiled

<XXXXX@gmail.com>: host gmail-smtp-in.l.google.com[google.ip.ip.ip] said:
    550-5.7.26 This mail is unauthenticated, which poses a security risk to the
    550-5.7.26 sender and Gmail users, and has been blocked. The sender must
    550-5.7.26 authenticate with at least one of SPF or DKIM. For this message,
    550-5.7.26 DKIM checks did not pass and SPF check for [massarcloud.sa] did
    not 550-5.7.26 pass with ip: [!!!!!smarty_hostingip_why_not_the_smpip!!!!!]. The sender should visit
    550-5.7.26  https://support.google.com/mail/answer/81126#authentication for
    550 5.7.26 instructions on setting up authentication.
    m15-20020aa7c2cf000000b00532c440746fsi9441448edp.178 - gsmtp (in reply to
    end of DATA command)

the bounce email was show the hosting IP , not the used SMTP IPs.

this should be tested again.

mshannaq commented 10 months ago

I've tested this on a live environment by updating .env file and set mail protocol in the email.string setting with email.fromEmail set to noreply@yourdomain. When using this configuration and replacing 'yourdomain' with your actual domain or subdomain used for SmartyURL, emails were sent without any issues.

If you encounter problems with the smtp protocol, consider switching to the mail protocol as a temporary solution.

I'll conduct further testing with the smtp protocol and provide updates on this issue in the future.

This is a sample of mail configuration in mail that I have used: (replacing 'yourdomain' with your actual domain or subdomain used for SmartyURL)


#mail protocol: choose beteween mail, sendmail, smtp
#and we advice you to choose smtp and enter emtp info below
email.string $protocol = 'mail';

#choose the default sender mail
email.fromEmail = noreplay@yourdomain

#choose the default sender name
email.fromName   = 'SmartyURL'
datamweb commented 10 months ago

Email settings should be as follows:

For gmail(smtp):

<?php

namespace Config;

use CodeIgniter\Config\BaseConfig;

class Email extends BaseConfig
{
    public string $fromEmail  = 'info@codeIgniter4.ir';
    public string $fromName   = 'codeIgniter4DotIR';
    public string $recipients = '';

    /**
     * The "user agent"
     */
    public string $userAgent = 'CodeIgniter4.ir';

    /**
     * The mail sending protocol: mail, sendmail, smtp
     */
    public string $protocol = 'smtp';

    /**
     * The server path to Sendmail.
     */
    public string $mailPath = '/usr/sbin/sendmail';

    /**
     * SMTP Server Address
     */
    public string $SMTPHost = 'smtp.gmail.com';

    /**
     * SMTP Username
     */
    public string $SMTPUser = 'yourmail@gmail.com';

    /**
     * SMTP Password
     */
    public string $SMTPPass = 'set app email password here @see https://myaccount.google.com/apppasswords';

    /**
     * SMTP Port
     */
    public int $SMTPPort = 587;

    /**
     * SMTP Timeout (in seconds)
     */
    public int $SMTPTimeout = 5;

    /**
     * Enable persistent SMTP connections
     */
    public bool $SMTPKeepAlive = false;

    /**
     * SMTP Encryption. Either tls or ssl
     */
    public string $SMTPCrypto = 'tls';

    /**
     * Enable word-wrap
     */
    public bool $wordWrap = true;

    /**
     * Character count to wrap at
     */
    public int $wrapChars = 76;

    /**
     * Type of mail, either 'text' or 'html'
     */
    public string $mailType = 'html';

    /**
     * Character set (utf-8, iso-8859-1, etc.)
     */
    public string $charset = 'UTF-8';

    /**
     * Whether to validate the email address
     */
    public bool $validate = false;

    /**
     * Email Priority. 1 = highest. 5 = lowest. 3 = normal
     */
    public int $priority = 3;

    /**
     * Newline character. (Use “\r\n” to comply with RFC 822)
     */
    public string $CRLF = "\r\n";

    /**
     * Newline character. (Use “\r\n” to comply with RFC 822)
     */
    public string $newline = "\r\n";

    /**
     * Enable BCC Batch Mode.s
     */
    public bool $BCCBatchMode = false;

    /**
     * Number of emails in each BCC batch
     */
    public int $BCCBatchSize = 200;

    /**
     * Enable notify message from server
     */
    public bool $DSN = false;
}

For your server mail(mail)

<?php

namespace Config;

use CodeIgniter\Config\BaseConfig;

class Email extends BaseConfig
{
    public string $fromEmail  = 'no-reply@codeigniter4.ir';
    public string $fromName   = 'codeigniter4DotIr';
    public string $recipients = '';

    /**
     * The "user agent"
     */
    public string $userAgent = 'CodeIgniter4ir';

    /**
     * The mail sending protocol: mail, sendmail, smtp
     */
    public string $protocol = 'mail';

    /**
     * The server path to Sendmail.
     */
    public string $mailPath = '/usr/sbin/sendmail';

    /**
     * SMTP Server Address
     */
    public string $SMTPHost = 'mail.codeigniter4.ir';

    /**
     * SMTP Username
     */
    public string $SMTPUser = 'no-reply@codeigniter4.ir';

    /**
     * SMTP Password
     */
    public string $SMTPPass = 'set email password here!!';

    /**
     * SMTP Port
     */
    public int $SMTPPort = 465;

    /**
     * SMTP Timeout (in seconds)
     */
    public int $SMTPTimeout = 5;

    /**
     * Enable persistent SMTP connections
     */
    public bool $SMTPKeepAlive = false;

    /**
     * SMTP Encryption. Either tls or ssl
     */
    public string $SMTPCrypto = 'tls';

    /**
     * Enable word-wrap
     */
    public bool $wordWrap = true;

    /**
     * Character count to wrap at
     */
    public int $wrapChars = 76;

    /**
     * Type of mail, either 'text' or 'html'
     */
    public string $mailType = 'html';

    /**
     * Character set (utf-8, iso-8859-1, etc.)
     */
    public string $charset = 'UTF-8';

    /**
     * Whether to validate the email address
     */
    public bool $validate = false;

    /**
     * Email Priority. 1 = highest. 5 = lowest. 3 = normal
     */
    public int $priority = 3;

    /**
     * Newline character. (Use “\r\n” to comply with RFC 822)
     */
    public string $CRLF = "\r\n";

    /**
     * Newline character. (Use “\r\n” to comply with RFC 822)
     */
    public string $newline = "\r\n";

    /**
     * Enable BCC Batch Mode.
     */
    public bool $BCCBatchMode = false;

    /**
     * Number of emails in each BCC batch
     */
    public int $BCCBatchSize = 200;

    /**
     * Enable notify message from server
     */
    public bool $DSN = false;
}