首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为Sharetribe配置SMTP

为Sharetribe配置SMTP
EN

Stack Overflow用户
提问于 2019-08-01 08:47:33
回答 1查看 249关注 0票数 2

我使用了本教程中的Gmail设置,它运行得很好:

教程:https://freedif.org/how-to-install-sharetribe-for-ubuntu-16-04

代码语言:javascript
复制
# Email configurations: (Sendmail + Gmail)
Login to your gmail account, enable imap.
Let the access here first: https://www.google.com/settings/security/lesssecureapps
Go to: https://accounts.google.com/b/0/DisplayUnlockCaptcha

sudo apt-get install sendmail mailutils sendmail-bin

folder and configuration file::
    sudo mkdir -m 700 /etc/mail/authinfo/
    sudo su
    cd /etc/mail/authinfo/
    sudo nano gmail-auth
        AuthInfo: "U:root" "I:myemail@gmail.com" "P:mypass"
the hash map:
    sudo makemap hash gmail-auth < gmail-auth
configure your sendmail:
    sudo nano /etc/mail/sendmail.mc
        paste just before the first MAILER definition line: (` and ' inconsistency is OK!)
            define(`SMART_HOST',`[smtp.gmail.com]')dnl
            define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl
            define(`ESMTP_MAILER_ARGS', `TCP $h 587')dnl
            define(`confAUTH_OPTIONS', `A p')dnl
            TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
            define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
            FEATURE(`authinfo',`hash -o /etc/mail/authinfo/gmail-auth.db')dnl
Now rebuild the sendmail configuration and restart it:
    make -C /etc/mail
    restart sendmail

Configure Sharetribe to use Sendmail:
    exit root user CTRL+D
    nano ~/sharetribe/config/config.yml
        mail_delivery_method: "sendmail"

然而,我想要一个品牌从电子邮件,而不是一个gmail。因此,我继续修改上面的代码,以便能够使用SMTP发送电子邮件:

代码语言:javascript
复制
mail_delivery_method: "smtp"
smtp_email_address: "myuser@example.com"
smtp_email_port: 465
smtp_email_domain: "smtpserver.example.com"
smtp_email_user_name: "myuser@example.com"
smtp_email_password: "mypass"

虽然我尝试了很多东西,但都没有用。服务器是一个数字海洋VPS,但电子邮件是由主机从DNS配置处理。是的,我的品牌电子邮件与前景很好。这里还有防火墙配置:

代码语言:javascript
复制
     To                         Action      From
     --                         ------      ----
[ 1] OpenSSH                    ALLOW IN    Anywhere
[ 2] Apache Full                ALLOW IN    Anywhere
[ 3] 11211                      ALLOW IN    Anywhere
[ 4] 25                         ALLOW IN    Anywhere
[ 5] 465                        ALLOW IN    Anywhere
[ 6] 587                        ALLOW IN    Anywhere
[ 7] OpenSSH (v6)               ALLOW IN    Anywhere (v6)
[ 8] Apache Full (v6)           ALLOW IN    Anywhere (v6)
[ 9] 11211 (v6)                 ALLOW IN    Anywhere (v6)
[10] 25 (v6)                    ALLOW IN    Anywhere (v6)
[11] 465 (v6)                   ALLOW IN    Anywhere (v6)
[12] 587 (v6)                   ALLOW IN    Anywhere (v6)

下面是一些调试信息,以了解当我试图发送电子邮件时会发生什么:

代码语言:javascript
复制
mysuser@example:~/sharetribe$ RAILS_ENV=production rake jobs:work


[Worker(host:example.com pid:2407)] Starting job worker
2019-07-31T13:42:52-0700: [Worker(host:example.com pid:2407)] Starting job worker
[Worker(host:example.com pid:2407)] Job CreateMemberEmailBatchJob (id=1) (queue=default) RUNNING
2019-07-31T13:43:12-0700: [Worker(host:example.com pid:2407)] Job CreateMemberEmailBatchJob (id=1) (queue=default) RUNNING
{"tag":"delayed_job","free":"Running job","type":"running","structured":{"job_name":"CreateMemberEmailBatchJob","args":{"sender_id":"123","community_id":1,"content":"123123","locale":"any","mode":"all_users"}}}
{"tag":"delayed_job","free":"Job success","type":"success","structured":{"job_name":"CreateMemberEmailBatchJob","args":{"sender_id":"123","community_id":1,"content":"123123","locale":"any","mode":"all_users"}}}
[Worker(host:example.com pid:2407)] Job CreateMemberEmailBatchJob (id=1) (queue=default) COMPLETED after 0.7504
2019-07-31T13:43:13-0700: [Worker(host:example.com pid:2407)] Job CreateMemberEmailBatchJob (id=1) (queue=default) COMPLETED after 0.7504
[Worker(host:example.com pid:2407)] Job CommunityMemberEmailSentJob (id=2) (queue=default) RUNNING
2019-07-31T13:43:13-0700: [Worker(host:example.com pid:2407)] Job CommunityMemberEmailSentJob (id=2) (queue=default) RUNNING
{"tag":"delayed_job","free":"Running job","type":"running","structured":{"job_name":"CommunityMemberEmailSentJob","args":{"sender_id":"123","recipient_id":"123","community_id":1,"content":"123123","locale":"any","test_to_yourself":null}}}

127.0.0.1:11211 failed (count: 0) Errno::ECONNREFUSED: Connection refused - connect(2) for "127.0.0.1" port 11211
DalliError: No server available
127.0.0.1:11211 failed (count: 1) Errno::ECONNREFUSED: Connection refused - connect(2) for "127.0.0.1" port 11211
127.0.0.1:11211 is down


DalliError: No server available
{"tag":"action_mailer","free":"Delivering email","type":"delivering_email","structured":{"to":["mysuser@example.com"],"from":["info@example.com"],"subject":"A new message from the example com team"}}

那么,如何使用SMTP从品牌域发送电子邮件呢?

或者我可以跳过所有这些,尝试配置sendmail来使用我的品牌域而不是gmail?

EN

回答 1

Stack Overflow用户

发布于 2020-08-20 13:11:51

我用的是品牌邮件。我可以看出端口可能有问题。检查这条线

代码语言:javascript
复制
# we have `:enable_starttls_auto => true` and we use 465. It works
smtp_email_port: 465

除了:enable_starttls_auto => true,我们还在production.rb中有:ssl => true

在我们的例子中,我们使用zoho,因此我们引用了这份文件

传出服务器名称: smtp.zoho.in 端口: 465与SSL或 港口: 587与TLS

请为您的供应商检查此部分。您可能需要为非ssl尝试587端口。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57305137

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档