[BUG] Can't send emails from my app with email@1.2.1


#1

[UPDATE] If I downgrade email to email@1.2.0 I can send emails just fine!!! maybe this is a regression of latest PR #8605 https://github.com/meteor/meteor/pull/8605/files#diff-8b2faad35ab5c720c37a39b84135fe14

Hi! I’m having a really bad time with this. I can run an email example from here https://github.com/themeteorchef/using-the-email-package.

I have setup my google apps account with a temporary MAIL_URL in /imports/startup/server/index.js:

process.env.MAIL_URL = ‘smtp://user%40domain.com:Password_With%40Character@smtp.gmail.com:465’;

With that I can send emails from the example app just fine.

I implemented the very same code in my actual meteor project, everything seems to be ok, but the messages never get delivered!

Just to be clear, I’m testing from the same machine, with two consoles running meteor, one with meteor --port 3000 and the other with meteor --port 3002.

My server method in my actual app (not the demo one that works fine) looks like this, if you take a look at line console.log(‘Mail Sent…?’);, it never gets printed:

import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import { Email } from 'meteor/email';

Meteor.methods({
  sendMessage(message) {
    check(message, Object);

    Meteor.defer(() => {
      Email.send({
        to: 'GhiaMar <user1@domain.com>',
        from: 'user2@domain.com',
        subject: `${message.message}`,
        text: `Mensaje: ${message.message} \r\nNombre: ${message.name} \r\neMail: ${message.email}\r\n`,
        html: `<p>Mensaje: ${message.message}</p><p>Nombre: ${message.name}</p><p>eMail: ${message.email}</p>`,
      });

      console.log('Mail Sent...?');
    });

    console.log('Sending mail');
  },
});

In the serve console I get I20170513-17:51:22.894(-3)? Sending mail but I expect to get XXXXXXXXXX? Mail Sent…? at some point, but never happens.

Is there any chance to get this working? I really don’t get what’s wrong, because in the demo app, it works just fine…

PS: Just in case, I’m sending my package.json and meteor packages file

Meteor packages file:

meteor-base@1.0.4             # Packages every Meteor app needs to have
mobile-experience@1.0.4       # Packages for a great mobile UX
mongo@1.1.16                   # The database Meteor supports right now
reactive-var@1.0.11            # Reactive variable for tracker
session@1.1.7
tracker@1.1.2                 # Meteor's client-side reactive programming library

standard-minifier-css@1.3.4   # CSS minifier run for production mode
standard-minifier-js@2.0.0    # JS minifier run for production mode
es5-shim@4.6.15                # ECMAScript 5 compatibility for older browsers.
ecmascript@0.7.2              # Enable ECMAScript2015+ syntax in app code

accounts-password@1.3.5
accounts-base@1.2.16
check@1.2.5
audit-argument-checks@1.0.7
browser-policy@1.1.0

fourseven:scss@4.5.0
alanning:roles
themeteorchef:bert
static-html@1.1.11
xolvio:cleaner
practicalmeteor:mocha
xolvio:backdoor
mdg:validated-method
dburles:factory@1.0.0
ddp-rate-limiter@1.0.7
shell-server@0.2.3
aldeed:collection2-core@2.0.0
ostrio:files
ostrio:meteor-root
tunifight:loggedin-mixin

package.json:

{
  "name": "meteor-server",
  "version": "1.0.0",
  "description": "Server para la app.",
  "license": "MIT",
  "scripts": {
    "start": "meteor --settings settings-development.json",
    "test": "meteor test --driver-package practicalmeteor:mocha --port 5000",
    "chimp-watch": "chimp --ddp=http://localhost:3000 --watch --mocha --path=tests",
    "chimp-test": "chimp --ddp=http://localhost:3000 --mocha --path=tests",
    "staging": "meteor deploy staging.meteor.com --settings settings-development.json",
    "production": "meteor deploy production.meteor.com --settings settings-production.json"
  },
  "dependencies": {
    "babel-runtime": "^6.23.0",
    "bcrypt": "^1.0.2",
    "bootstrap": "^3.3.7",
    "jquery": "^2.2.4",
    "jquery-validation": "^1.15.1",
    "meteor-node-stubs": "^0.2.6",
    "prop-types": "^15.5.8",
    "react": "^15.5.4",
    "react-addons-pure-render-mixin": "^15.5.2",
    "react-bootstrap": "^0.31.0",
    "react-dom": "^15.5.4",
    "react-komposer": "^2.0.0",
    "react-router-bootstrap": "^0.24.2",
    "react-router-dom": "^4.1.1",
    "simpl-schema": "^0.2.3"
  },
  "devDependencies": {
    "babel-eslint": "^7.2.2",
    "babel-plugin-transform-class-properties": "^6.24.1",
    "chimp": "^0.41.2",
    "eslint": "^3.8.1",
    "eslint-config-airbnb": "^12.0.0",
    "eslint-import-resolver-meteor": "^0.4.0",
    "eslint-plugin-import": "^1.16.0",
    "eslint-plugin-jsx-a11y": "^2.2.3",
    "eslint-plugin-meteor": "^4.0.1",
    "eslint-plugin-react": "^6.4.1"
  }
}

#3

Hi razor,

First try to check if you get your email as an outpunt on the console. You can do this if you don’t set MAIL_URL anywere.

If you succed seeing the console output

Then try

try to set it as an OS enviorment variable:

Linux:

MAIL_URL = 'smtp://user%40domain.com:Password_With%40Character@smtp.gmail.com:465'

Windows:

SET MAIL_URL = 'smtp://user%40domain.com:Password_With%40Character@smtp.gmail.com:465'

#4

Hi @weissi8! The issue is a regression of latest PR #8605. if I downgrade email to 1.2.0 it works!!! I mean adding email@1.2.0 to my meteor/packages file


#5

Well, the issue ended up being my EMAIL_URL, it should start with smtps.

Now looks like this and works with email@1.2.1

process.env.MAIL_URL = ‘smtps://user%40domain.com:Password_With%40Character@smtp.gmail.com:465’;


#6

Thanks for your note. Did not yet upgrade package.


#7

I’m pretty sure this was mentioned a few times recently. I was having an issue with email@1.2.1, where it would fail silently. What fixed it for me was simply removing the email package (meteor remove email) and installing it again (meteor add email). For most people, this seems to resolve the issue.


#8

i have the same issue. after updating my Meteor project from 1.4 to 1.5 the email throw an error now. it says Greeting never received. i tried changing port, add smtps but none was working. i also tried to remove and add the email package, and upgrade the email to 1.2.3 but still not working… any help? thanks.