在我的Rails应用程序中,我使用这个宝石来与Gmail API交互:https://github.com/gmailgem/gmail
以下是我在发送电子邮件方法中的代码:
gmail = Gmail.connect(params[:email], params[:password])
@email = params[:email]
email = gmail.compose do
to @email
subject "Having fun in Puerto Rico!"
body "Spent the day on the road..."
end
email.deliver!
我收到了这个错误:
An SMTP To address is required to send a message. Set the message smtp_envelope_to, to, cc, or bcc address.
为什么电子邮件变量无法传递到块中?如何传入动态电子邮件地址?
@email
有任何值吗?它是空的还是 nil? - Wand Maker