import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.Channel;
public class SendEmail {
private static String hostname = "127.0.0.1";
private static String username = "trabbit";
private static String password = "password";
private static String vhost = "/";
private static String outbox = "outbound_test: Windows Client";
private static Integer port = 5672;
public static void main(String[] argv) throws Exception {
ConnectionFactory factory = new ConnectionFactory();
factory.setHost(hostname);
factory.setUsername(username);
factory.setPassword(password);
factory.setVirtualHost(vhost);
factory.setPort(port);
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();
channel.queueDeclare(outbox, true, false, false, null);
String message = "gen_smtp_client:send({\"what...@test.com\", [\"and...@hijacked.us\"],\n" +
" \"Subject: testing\\r\\nFrom: Andrew Thompson \\r\\nTo: Some Dude \\r\\n\\r\\nThis is the email body\"},\n" +
" [{relay, \"smtp.gmail.com\"}, {username, \"user...@gmail.com\"}, {password, \"password\"}])";
// publish the message on the queue
channel.basicPublish("", "", null, message.getBytes());
// some output
System.out.println("Sent: '" + message + "'");
// close the channel
channel.close();
// close the connection
connection.close();}
}{rabbitmq_email, [
% gen_smtp server parameters
% see https://github.com/Vagabond/gen_smtp#server-example
{server_config, [
[{port, 2525}, {protocol, tcp}, {domain, "example.com"}, {address,{0,0,0,0}}]
]},
% inbound email exchanges: [{email-domain, {vhost, exchange}}, ...}
{email_domains,
[{<<"example.com">>, {<<"/">>, <<"email-in">>}}
]},
% outbound email queues: [{{vhost, queue}, email-domain}, ...]
{email_queues,
[{{<<"/">>, <<"email-out">>}, <<"example.com">>}
]},
% sender indicated in the From header
{client_sender, "nor...@example.com"},
% gen_smtp client parameters
% see https://github.com/Vagabond/gen_smtp#client-example
{client_config, [
{relay, "smtp.example.com"}
]}
]}String message = "{ \"envelope\": \"" + fromAddress + "\", "
+ "\"recipient\": \"" + recipientEmail + "\", "
+ "\"body\": \"" + "From: " + fromAddress + "\r\nTo: "
+ recipientEmail
+ "\r\nSubject: Example subject\r\n\r\n"
+ "This is the example message text\" }";On 02/03/2015 21:53, Mäū Cárdenas wrote:
> |Stringmessage ="gen_smtp_client:send({\"whatev...@test.com\",
Status: * = running on rabbit@MauBuntu
|/
[e*] amqp_client 3.4.4
[ ] cowboy 0.5.0-rmq3.4.4-git4b93c2d
[E*] gen_smtp 0.9.0-rmq0.0.0-gita62c02e
[e*] mochiweb 2.7.0-rmq3.4.4-git680dba8
[E*] rabbitmq_amqp1_0 3.4.4
[ ] rabbitmq_auth_backend_ldap 3.4.4
[ ] rabbitmq_auth_mechanism_ssl 3.4.4
[ ] rabbitmq_consistent_hash_exchange 3.4.4
[ ] rabbitmq_federation 3.4.4
[ ] rabbitmq_federation_management 3.4.4
[E*] rabbitmq_management 3.4.4
[e*] rabbitmq_management_agent 3.4.4
[ ] rabbitmq_management_visualiser 3.4.4
[E*] rabbitmq_mqtt 3.4.4
[ ] rabbitmq_shovel 3.4.4
[ ] rabbitmq_shovel_management 3.4.4
[ ] rabbitmq_stomp 3.4.4
[ ] rabbitmq_test 3.4.4
[ ] rabbitmq_tracing 3.4.4
[e*] rabbitmq_web_dispatch 3.4.4
[ ] rabbitmq_web_stomp 3.4.4
[ ] rabbitmq_web_stomp_examples 3.4.4
[ ] sockjs 0.3.4-rmq3.4.4-git3132eb9
[e*] webmachine 1.10.3-rmq3.4.4-gite9359c7lided] generate deps
[elided] fix test deps
sed -e 's|build/deps.mk|$(DEPS_FILE)|' build/deps.mk > build/deps.mk.tmp && mv build/deps.mk.tmp build/deps.mk
escript ../generate_app src/rabbitmq_email.app.src ebin/rabbitmq_email.app ./src
sed -n -e 's|^.*{vsn, *"\([^"]*\)".*$|ORIGINAL_VERSION:=\1|p' <ebin/rabbitmq_email.app >build/version.mk
rm -rf ../rabbitmq-server/dist
make -C ../rabbitmq-server
make[1]: Entering directory `/home/mau777/rabbitmq-public-umbrella/rabbitmq-server'
Makefile:403: deps.mk: No such file or directory
xsltproc --novalid --stringparam modulename "`basename src/rabbit_ctl_usage.erl .erl`" \
docs/usage.xsl docs/rabbitmqctl.1.xml > src/rabbit_ctl_usage.erl.tmp
/bin/sh: 1: xsltproc: not found
make[1]: *** [src/rabbit_ctl_usage.erl] Error 127The main plugin is named “rabbitmq_email” and it needs to be activated as described here:
http://www.rabbitmq.com/plugin-development.html
You will not see the SMTP listening port in the “Port and contexts” table because the plugin is not integrated with it. However it will be shown by the standard “netstat” command.
Petr
--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
rabbitmq-user...@googlegroups.com.
To post to this group, send email to
rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
make
../do-package.mk:168: ../rabbitmq-gen-smtp/package.mk: No such file or directory
[elided] generate deps
[elided] fix test deps
sed -e 's|../coverage/build/deps.mk|$(DEPS_FILE)|' ../coverage/build/deps.mk > ../coverage/build/deps.mk.tmp && mv ../coverage/build/deps.mk.tmp ../coverage/build/deps.mk
[elided] generate deps
[elided] fix test deps
sed -e 's|../rabbitmq-gen-smtp/build/deps.mk|$(DEPS_FILE)|' ../rabbitmq-gen-smtp/build/deps.mk > ../rabbitmq-gen-smtp/build/deps.mk.tmp && mv ../rabbitmq-gen-smtp/build/deps.mk.tmp ../rabbitmq-gen-smtp/build/deps.mk
make: *** No rule to make target `../rabbitmq-gen-smtp/package.mk'. Stop.
To post to this group, send email to rabbit...@googlegroups.com.
sudo rabbitmq-plugins enable rabbitmq_email
The following plugins have been enabled:
gen_smtp
rabbitmq_email
Applying plugin configuration to rabbit@MauBuntu... failed.
Error: {"no such file or directory","rabbitmq_email.app"}> <mailto:rabbitmq-users+unsub...@googlegroups.com>.
sudo rabbitmq-plugins enable rabbitmq_email
The following plugins have been enabled:
gen_smtp
rabbitmq_email
Applying plugin configuration to rabbit@MauBuntu... failed.
Error: {"no such file or directory","rabbitmq_email.app"}