Newbie question on sending email from gae

7 views
Skip to first unread message

GregD

unread,
Dec 12, 2009, 11:51:02 PM12/12/09
to Google App Engine
Any help please. I'm trying to send email from my servlet. I
basically copied the code from the gae site. Im setting the from
address as the admin of the gae account (fyi also tried a normal gmail
account). In the admin console its saying the mails were sent, but Im
not seeing the email on the receiving end. Also there are no
exceptions being logged. my code is below.

Properties props = new Properties();
Session session = Session.getDefaultInstance(props, null);

StringBuffer sb = new StringBuffer();
sb.append("Name: " + name);
sb.append("Email: " + email);
sb.append("Phone: " + phone);
sb.append("Message: " + message);

try {
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress
("ad...@mygaeaccount.com"));
msg.setRecipient(Message.RecipientType.TO, new
InternetAddress("gr...@mygaeaccount.com"));
msg.setSubject("Contact Us Website Request");
msg.setText(sb.toString());
Transport.send(msg);

} catch (Exception e) {
Logger log = Logger.getLogger("Greg");
log.severe("Sending Mail Exception");
log.severe(e.getMessage());
}


m seleron

unread,
Dec 14, 2009, 10:03:28 PM12/14/09
to Google App Engine
For an easy confirmation
Please set and execute x...@gmail.com by which setFrom/setRecipient
logged in both dashboards of GAE.
In this way I was able to send things to normal.

please try.
thanks.

On 12月13日, 午後1:51, GregD <greg.du...@gmail.com> wrote:
> Any help please.   I'm trying to send email from my servlet.  I
> basically copied the code from the gae site.  Im setting the from
> address as the admin of the gae account (fyi also tried a normal gmail
> account).  In the admin console its saying the mails were sent, but Im
> not seeing the email on the receiving end.  Also there are no
> exceptions being logged.  my code is below.
>
>                 Properties props = new Properties();
>                 Session session = Session.getDefaultInstance(props, null);
>
>                 StringBuffer sb = new StringBuffer();
>                 sb.append("Name: " + name);
>                 sb.append("Email: " + email);
>                 sb.append("Phone: " + phone);
>                 sb.append("Message: " + message);
>
>                 try {
>             Message msg = new MimeMessage(session);
>             msg.setFrom(new InternetAddress
> ("ad...@mygaeaccount.com"));
>             msg.setRecipient(Message.RecipientType.TO, new
> InternetAddress("g...@mygaeaccount.com"));

Mohamed Dem Diarra

unread,
Dec 17, 2009, 11:27:38 AM12/17/09
to Google App Engine
If you are running your app with the dev server, it does not send an
email unless you set it up to do so.

Here is what the GAE documentation says:
Using Mail
The development web server can send email for calls to the App Engine
mail service. To enable email support, the web server must be given
options that specify a mail server to use. The web server can use an
SMTP server, or it can use a local installation of Sendmail.
To enable mail support with an SMTP server, use the --smtp_host, --
smtp_port, --smtp_user and --smtp_password options with the
appropriate values.
dev_appserver.py --smtp_host=smtp.example.com --smtp_port=25 \
--smtp_user=ajohnson --smtp_password=k1tt3ns myapp
To enable mail support with Sendmail, use the --enable_sendmail
option. The web server will use the sendmail command to send email
messages, with your installation's default configuration.
dev_appserver.py --enable_sendmail myapp
If mail is not enabled with either SMTP or Sendmail, then attempts to
send email from the application will do nothing, and appear successful
in the application.

http://code.google.com/appengine/docs/python/tools/devserver.html#Using_Mail

Thanks,
-- Mohamed D.

On Dec 12, 10:51 pm, GregD <greg.du...@gmail.com> wrote:
> Any help please.   I'm trying to send email from my servlet.  I
> basically copied the code from the gae site.  Im setting the from
> address as the admin of the gae account (fyi also tried a normal gmail
> account).  In the admin console its saying the mails were sent, but Im
> not seeing the email on the receiving end.  Also there are no
> exceptions being logged.  my code is below.
>
>                 Properties props = new Properties();
>                 Session session = Session.getDefaultInstance(props, null);
>
>                 StringBuffer sb = new StringBuffer();
>                 sb.append("Name: " + name);
>                 sb.append("Email: " + email);
>                 sb.append("Phone: " + phone);
>                 sb.append("Message: " + message);
>
>                 try {
>             Message msg = new MimeMessage(session);
>             msg.setFrom(new InternetAddress
> ("ad...@mygaeaccount.com"));
>             msg.setRecipient(Message.RecipientType.TO, new

> InternetAddress("g...@mygaeaccount.com"));

Reply all
Reply to author
Forward
0 new messages