• Resolved boostxd

    (@boostxd)


    Hi,

    I’m setting up mailing service in my site using AWS SES SMTP Interface, but I’m encountering issues. First, I assure that the credentials are correct. I checked them so many times. Second, I don’t want to use a plugin to setup SMTP Server because of resources usage, resources are very scarce! What complicates my life is the fact I’m unable to successfully debug SMTP errors, If I could do that I’d already fixed the issue.

    I’m trying to setup SMTP in my theme’s functions.php file

    // SMTP email settings
        define( 'SMTP_username', 'SMTP_USERNAME' );  // username of host like Gmail
        define( 'SMTP_password', 'SMTP_PASSWORD' );   // password for login into the App
        define( 'SMTP_server', 'email-smtp.us-east-1.amazonaws.com' );     // SMTP server address
        define( 'SMTP_FROM', 'BUSINESS_MAIL' );   // Your Business Email Address
        define( 'SMTP_NAME', 'SMTP_NAME' );   //  Business From Name
        define( 'SMTP_PORT', '587' );     // Server Port Number
        define( 'SMTP_SECURE', 'tls' );   // Encryption - ssl or tls
        define( 'SMTP_AUTH', true );  // Use SMTP authentication (true|false)
        define( 'SMTP_DEBUG',   1 );  // for debugging purposes only<code></code>
    
    add_action( 'phpmailer_init', 'my_phpmailer_smtp' );
    	function my_phpmailer_smtp( $phpmailer ) {
    		$phpmailer->isSMTP();     
    		$phpmailer->Host = SMTP_server;  
    		$phpmailer->SMTPAuth = SMTP_AUTH;
    		$phpmailer->Port = SMTP_PORT;
    		$phpmailer->Username = SMTP_username;
    		$phpmailer->Password = SMTP_password;
    		$phpmailer->SMTPSecure = SMTP_SECURE;
    		$phpmailer->From = SMTP_FROM;
    		$phpmailer->FromName = SMTP_NAME;
    	}

    I tried to set WP_DEGUG true in the file wp-config.php, but nothing. Does anyone know a better approach?

    • This topic was modified 2 years, 10 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic
    • This topic was modified 2 years, 9 months ago by Jan Dembowski.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • I’m sure you know that AWS SES authentication is not as simple as getting username and password correct.

    I’m not a developer… so I can only suggest you use an SMTP plugin to test to be 100% sure the problem is not in your SES configuration. Most of these plugins will also have the kind of logging info you’re looking for.

    Then you can port the 100% tested and functioning settings to your theme’s functions.php or wp-config.php file and get rid of the plugin.

    https://www.ads-software.com/plugins/post-smtp/

    Just to add, the wp mail function doesn’t log any useful messages on email failure.

    To log the returned message I use code like this

    add_action( 'wp_mail_failed', function ( $wp_error ) {
    		/**  @var $wp_error \WP_Error */
    		if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG && is_wp_error( $wp_error ) ) {
    			trigger_error( 'WP Email - wp_mail error msg : ' . $wp_error->get_error_message(), E_USER_WARNING );
    		}
    	}, 10, 1 );
    Thread Starter boostxd

    (@boostxd)

    Hi, thanks for your help! I was doing some tests in development environment and I kinda forgot to also test the codes on local web server first (I initially thought it wouldn’t work because it’s localhost and I can’t possibly add it to list of verified domains, that’s why I jumped to production server)… I tested with post smtp and my own code – they are doing fine. In final it turns out Amazon is blocking port 587. It is not firewall because I added rule to unblock that that port in AWS Console. It is not OS-level firewall either because I disabled the daemon or service from running in background.

    Out going from Amazon SES? So I had a similar issue on Google Computer engine where you have to use a custom port like 2525

    Have you tried 2587 or 2465 as they are supported by SES

    Thread Starter boostxd

    (@boostxd)

    Hi @alanfuller, I’ll do that when I move the codes to production server again. Thanks!

    • This reply was modified 2 years, 10 months ago by boostxd.
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[NSFW] How to correctly debug SMTP Issues on WordPress?’ is closed to new replies.