简体   繁体   中英

Rails and Gmail SMTP, how to use a custom from address

I've got my Rails (2.1) app setup to send email via Gmail, however whenever I send an email no matter what I set the from address to in my ActionMailer the emails always come as if sent from my Gmail email address. Is this a security restriction they've put in place at Gmail to stop spammers using their SMTP?

Note: I've tried both of the following methods within my ActionMailer (just in case):

@from = me@mydomain.com
from 'me@mydomain.com'

我相信这只是Gmail通过SMTP发送邮件时所做的事情,因为有人提到他们在使用SMTP发送邮件的教程中执行此操作。

I think I tried and failed in the past myself, but I did just come across this on the gmail site: http://mail.google.com/support/bin/answer.py?ctx=gmail&hl=en&answer=22370

Looks like you can specify a custom "From" address within gmail, and perhaps at that point, see if setting @from will work (now that gmail knows about your custom from address).

This is most likely to stop people trying to send email from addresses that Google can't verify that the sender owns. This is fairly common amongst mail providers, and is probably a safeguard to stop people using Google's services for sending spam.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM