현재 sendgrid를 통해 이메일을 보내고 있으며 현재 새 사용자에게 이메일을 보내고 있습니다. ... 그러나 이상하게도 매우 유사한 이메일 전송 옵션이 작동하지 않습니다.받는 사람을 포함하는 전체 이메일은 로그에 표시되지만 결코 수신되지는 않습니다.Rails + SendGrid 인증되지 않은 발신자는 허용되지 않습니다.
이니셜 라이저에서 mail.rb 파일에서 : 여기
내가 가진 무엇 사용자 이름과 암호를ActionMailer::Base.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => '587',
:authentication => :plain,
:user_name => configatron.sendgrid.username,
:password => configatron.sendgrid.password,
:domain => 'heroku.com'
}
ActionMailer::Base.delivery_method = :smtp
다른 곳에서 정의되고 - 그들은 그들의 올바른 값이 확인된다
새 사용자가 등록하면 UserMailer 클래스에 전화를 걸어 다음을 수행합니다.
def welcome_email(user)
@email = user.email
@name = user.full_name
mail(to: @email, subject: "Welcome!")
end
,363,210
그리고 작업자는 단순히 다음을 수행하여 호출
UserMailer.welcome_email(user).deliver
이 많은 작품; 나는 그 이메일을 받는다.
하지만 다른 방법으로 이메일을 보내려고 할 때 마술 같은 일이 일어납니다.
def request(org, recipient, item)
@org = org
@recipient = recipient
@item = item
mail(to: @org.email, subject: "A new request has been posted!")
end
(근로자의 외부 이번에는 내가 쉽게 디버깅 할 수 있지만) 같은 기능을 사용 :
UserMailer.request(org, recipient, item).deliver
이메일 완벽 터미널에 표시되는 것과 동일한 UserMailer 클래스에서
:Sent mail to [email protected] (4717ms)
Date: Mon, 31 Dec 2012 01:03:35 -0800
From: [email protected]
To: [email protected]
Message-ID: <[longhexstring]@localhost.localdomain.mail>
Subject: A new request has been posted!
Mime-Version: 1.0
Content-Type: multipart/alternative;
boundary="--==_mimepart_50e154e769903_3c41bba7ec576d5";
charset=UTF-8
Content-Transfer-Encoding: 7bit
----==_mimepart_50e154e769903_3c41bba7ec576d5
Date: Mon, 31 Dec 2012 01:03:35 -0800
Mime-Version: 1.0
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-ID: <[longhex]@localhost.localdomain.mail>
Hello world!
----==_mimepart_50e154e769903_3c41bba7ec576d5
Date: Mon, 31 Dec 2012 01:03:35 -0800
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-ID: <[longhex]@localhost.localdomain.
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
</head>
<body>
<p>
Hello world!
</p>
</body>
</html>
하지만 내 개인 이메일, 스팸 메일, 아무것도받지 못했습니다. 심지어 sendgrid도 요청 이메일을 보내달라고 요청하는 로그가 없습니다! 그러나 환영 전자 메일은 완벽하게 작동하며 심지어 sendgrid를 통해 기록됩니다. 한 그룹의 이메일은 보낼 수 있지만 다른 것은 보낼 수없는 것을 알지 못합니다. 그리고 이것은 정말로 당혹 스럽습니다. 구문에 명백한 오류가 없다면 나와 함께 뛰어 내리며, 사용하는 값은 올바른 데이터 유형이며 nil이 아닙니다.
이 이상한 문제에 대한 도움은 매우 감사하겠습니다.
다행히 해결되었습니다. 업데이트를 아래 답변으로 변환하면 사람들이 쉽게 찾을 수 있으므로 도움이 될 것입니다. – Swift
.env 작업을 한 번 수행 할 계획입니다. – limasxgoesto0