I'm hosting a site on Amazon's ec2 running a 64-bit version of CentOS.
The site has a simple Contact Us form that needs to send an email to several addresses when submitted (pretty basic).
Has anyone used Amazon's SES with Symfony2 and the Swiftmailer Bundle? And if so, do you recommend using SES or a more traditional email server for this type of task?
It is possible to send email via SES with the native SMTP transport shipped with the swiftmailer library. Examples below were tested using version 4.2.2.
Amazon SES requires usage of TLS encryption.
Swift_SmtpTransport transport class can be configured to use TLS encryption by passing tls as the third constructor argument:
require_once './vendor/swiftmailer/swiftmailer/lib/swift_required.php';
// Create the Transport
$transport = Swift_SmtpTransport::newInstance(
'email-smtp.us-east-1.amazonaws.com',
25,
'tls'
)
->setUsername('AWS_ACCESS_KEY')
->setPassword('AWS_SECRET_KEY')
;
// Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);
// Create a message
$message = Swift_Message::newInstance('Wonderful Subject')
->setFrom(array('example#example.org'))
->setTo(array('example#example.org' => 'John Doe'))
->setBody('Here is the message itself')
;
// Send the message
$result = $mailer->send($message);
In Symfony2, you can configure the swiftmailer service to use TLS encryption:
# app/config/config.yml
swiftmailer:
transport: smtp
host: email-smtp.us-east-1.amazonaws.com
username: AWS_ACCESS_KEY
password: AWS_SECRET_KEY
encryption: tls
Sending emails directly from a mailserver installed on an EC2 instance is not very reliable as EC2 IP addresses may be blacklisted. It is recommended to use a trusted mailserver so using SES seems to be a good idea.
Sending mails through SES via Symfony2 didn't work out of the box for me because I had the spool option configured in my config.yml.
Another problem I stumbled upon was the port. Port 25 and 587 work perfect but 465 got me a timeout.
And it's important that you are using the right SMTP server, at first I was using us-east-1 (because I copied it from an example) although my SMTP actually was email-smtp.eu-west-1.amazonaws.com
So here's my current config:
parameters:
mailer_transport: smtp
mailer_host: email-smtp.eu-west-1.amazonaws.com
mailer_user: AWS_ACCESS_KEY
mailer_password: AWS_SECRET_KEY
mailer_encryption: tls
mailer_port: 587
swiftmailer:
transport: %mailer_transport%
host: %mailer_host%
username: %mailer_user%
password: %mailer_password%
encryption: "%mailer_encryption%"
port: %mailer_port%
auth_mode: login
I found the problem by executing the following on my command line:
php app/console swiftmailer:debug
There's an SES transport prebuilt for swiftmailer. Very easy to set up:
https://github.com/jmhobbs/Swiftmailer-Transport--AWS-SES
If you can stick with the free tier limits (2K daily messages), I'd definitely recommend you to stick with SES instead of a traditional email server. It's simple, easy to integrate with most platforms, and you eliminate the maintenance and operation costs (although small, they are still there) for your email server. Of course, there are still data transfer costs when using SES, as you can see on Amazon SES pricing, but that might fit your needs as well.
Since december 2011 you can use smtp with switfmail but before The problem was that this bundle still don't have the implementation for work over EC2, but already exists. If you like send emails with some framework like switfmail you should have your password and key, and do something like this:
require_once 'lib/swift_required.php';
//Create the Transport
$transport = new Swift_AWSTransport(
'AWS_ACCESS_KEY',
'AWS_SECRET_KEY'
);
//Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);
//Create the message
$message = Swift_Message::newInstance()
->setSubject("What up?")
->setFrom(array('you#yourdomain.com'))
->setTo(array('them#theirdomain.com'))
->setBody("
For take your key go inside AWS Management Console" > "SMTP Settings" > "create my SMTP credentials"
And you are going to need install this extension :
https://github.com/jmhobbs/Swiftmailer-Transport--AWS-SES
but I repet this is only information. Now, you should verified your email account before in your AWS Management Console and later should work.
On more recent Symfony versions, support for SES is included. You can simply pass your credentials and set your stmp host in configuration.
See documentation for Symfony 3.4 and for Symfony 4.X
Just add 'tls' as third paramater. Works fine
Ex:
// Create the Transport
$transport = (new Swift_SmtpTransport('amazon-url', 587, 'tls'))
->setUsername('awsusernamexxxxxx')
->setPassword('awspasswordxxxxxx');
// Other codings
?>
Related
I am using Apache Ambari 2.7.3V. I am trying to configure Email Alerts. I have Followed the Below Link. But I am not getting any alerts To my Gmail. Below are my configurations
https://docs.cloudera.com/HDPDocuments/Ambari-2.7.4.0/managing-and-monitoring-ambari/content/amb_create_an_alert_notification.html
In Manage Alert Notifications I have configured All required configurations. like below.
Name: amabri Alerts
groups: All
Severity: WARNING, CRITICAL
Description : xxxxxxxx
METHOD: EMAIL
SMTP SERVER: smtp-relay.gmail.com
SMTP PORT : 587
I am not sure whether your issue has been resolved. But posting for other users' reference.
You need to set the app password to use Gmail SMTP. You have to enable two-step verification to enable the app password as below. In addition to that, the SMTP server for Gmail would be-smtp.gmail.com
.
If still, you are not getting emails then you can test the python script(from head node) here
and test the below:
Ssh to head node
Then edit the file -Sudo vi /etc/ambari-server/conf/log4j.properties
Modify - log4j.logger.alerts=INFO,alerts to log4j.logger.alerts=DEBUG,alerts
Add below line to Alerts section -
log4j.logger.org.apache.ambari.server.notifications.dispatchers=DEBUG,alerts
Save the file and restart ambari server service using usr/lib/hdinsight-common/scripts/restart_ambari_server.sh
Try to stop zookeeper on any one of the node and check for the ambari-server.log and amabri-alerts.log.
In /var/log/ambari-server, check ambari-alerts.log and ambari-server.log after an alert was fired.
When users are registered Laravel fires of a welcome email using Swiftmail configured to use SMTP with Mandrill. With the existing config, this works perfectly on my local installation.
When moving to the production server (Unmanaged, CentOS with WHM/Cpanel), the first HELO fails, giving this error:
Swift_TransportException in AuthHandler.php line 181:
Failed to authenticate on SMTP server with username "info#mydomain.com" using 2 possible
authenticators
in AuthHandler.php line 181
at Swift_Transport_Esmtp_AuthHandler->afterEhlo(object(Swift_SmtpTransport)) in
EsmtpTransport.php line 307
All other questions I can find with this error are about Gmail needing to have it's authentication weakened to allow the connection. This is directly with Mandrill so such things can't be the issue.
I've already checked the correct port (578) is open - nmap says it is.
That the credentials in mail.php are valid - API key is correct, so is user information.
And that the server can access the remote server - I can telnet smtp.mandrillapp.com without issue.
I'm running out of things to test for to fix.
Any suggestions welcome, and thank you in advance!
I want to use Mercury Mail as a mail server in a local network. I managed to set up everything and I am able to send mails from one client to another in this local network via the Mercury Mail server (part of Xampp) on Windows 7. The whole environment is set up locally, i.e. communication is only between local users and not with the outside world (internet).
What I want now: When a local user sends a mail to another local user, I want them to SMTP authenticate first. From Mercury Mail Admin Panel SMTP Server, I don't see such option. Could you point me to the documentation or guide me on how to do it? Thanks a lot.
Without any changes, email notifications stopped being sent from our continuous integration server which is a Teamcity 7.1 server. Up to now I've just used the default teamcity email configuration, which was this:
SMTP host: mail
SMTP port: 25
Send email messages from: Teamcity
SMTP login: <blank>
SMTP password: <blank>
Secure connection: none
Worked fine for last year or so. Now I'm trying to diagnose what is wrong, but I don't really know what the above configuration is doing... Is it pointing to a built-in mail server that is bundled with Teamcity? Is it pointing to the company's exchange server? Something else?
Teamcity does not have any bundled mail servers. This configuration point to your company's SMTP server. By occasion, SMTP server's name is 'mail'. So TC tries to connect to mail:25 and send messages 'from' 'Teamcity'
Please check if SMTP server's authentication settings were modified (e.g., anonymous access is now forbidden). Also please check 'teamcity-server.log' for error messages related to sending notifications.
I find a lot of details on the internet how to configure Oracle database to use PL/SQL commands to send an email from the database, but they're all using the SMTP server that the database is installed in (I think at least). If these emails are being sent to DBAs, then that's fine.
What about the scenario where an email is sent to customers? In this case wouldn't we want the email to be sent from an application server (e.g. DMZ), and NOT the database server?
I'm assuming the IP address of the database server (or other special information regarding the database server that we'd rather keep private) would be available in such an email. If this isn't true, my question has no merit.
Is it possible to generate an email from the database PL/SQL command(s) but have it sent to the customer from a proxy (e.g. application) server? So the email traffic route would be: database server --> application server --> customer. The added benefit is most email systems would be on the application server anyway so returned emails would go the application server.
If you're using UTL_SMTP, your code will have a line like this somewhere:
c := UTL_SMTP.open_connection( 'myhost', 25 );
The first parameter is the mail server. You should be able to set it to any server that your database server can connect to (via port 25).
They're not necessarily using the SMTP server that the "database is installed in" (not really sure what you mean by that). You define the system parameter SMTP_OUT_SERVER to configure the IP and port of the SMTP server. Oracle will send email to whatever server you define, as long as it is network accessible.
See this site for more information on setting up UTL_MAIL. Try it out. Look at the headers. See for yourself what it looks like.