Integrating FOSUserBundle reset email with Amazon SES - symfony

I configured my postfix to use Amazon SES when sending Emails.
I am trying to use FOSUserBundle's function to send email for user password reset.
Unfortunately, the mail never arrive to the mailbox, Amazon SES don't accept the emails forged by the FOSUserBundle.
Does anybody what is the matter with this email:
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=utf-8
MIME-Version: 1.0
Date: Mon, 15 Oct 2012 04:07:56 +0000
Message-ID: <1350274076.507b8c1c8cee8#www.yourownpoet.com>
From: quilly#YourOwnPoet.com
Subject: blablou
To: toto#gmail.com
Bcc:
<html><body>whatever</body></html>
This doesn't work neither:
Content-Type: multipart/alternative;
boundary="_=_swift_v4_1350274671507b8e6f82b5f_=_"
MIME-Version: 1.0
Date: Mon, 15 Oct 2012 04:17:51 +0000
Message-ID: <1350274671.507b8e6f99894#www.yourownpoet.com>
From: quilly#YourOwnPoet.com
Subject: blablou
To: toto#gmail.com
Bcc:
<html><body>whatever</body></html>
I created my own mailer service in order to try the emails with different headers (I use SwiftMailer). How should I forge my email so that it goes through Amazon SES?
EDIT:
I noticed that other mail with content-type: multipart/mixed; go through SES, but I don't manage to force the content-type field to this value. Is it possible to do it? Here is how i forge the email:
$message = \Swift_Message::newInstance()
->setContentType('multipart/mixed')
->setSubject('blablou')
->setFrom('quilly#YourOwnPoet.com')
->setTo('toto#gmail.com')
->setBody('<html><body>whatever</body></html>', 'text/html')
->addPart('fdsfsd', 'text/plain');
$this->mailer->send($message);
But the content-type is still 'multipart/alternative'..

Allright, found the answer... Leaving the post here, who knows might be useful to someone one day.
The problem wasn't coming from the content-type but from the sender's email adress!
Remember that you have to set which email addresses have the right to send email through ses.. And this email is case sensitive!
You can use the Mailer provided by FOSserBundle without problem, but configure it properly:
config.yml:
fos_user
resetting:
email:
template: YOPYourOwnPoetBundle:Emails:resetEmail.html.twig
from_email:
address: Quilly#YourOwnPoet.com /*set ses accepted email address here */
sender_name: Quilly
service:
mailer: fos_user.mailer.twig_swift

Related

Error 500 - The Simple Membership plugin cannot process this access request

I posted this on the plugin support page, but maybe someone here has experienced the same thing.
I am developing a web application that uses WordPress as a backend (Headless). That is, I consume the WordPress resources and database from the app created in Vue with Node.js through the Rest API.
User creation is simple and I have it figured out. What I’m having problems with is the login.
Apparently (and according to WordPress) the plugin Simple Wordpress Membership is blocking the login.
More details now:
I send my app username and password to WordPress by Rest API using node-fetch (GET method).
In WordPress I have an Endpoint inside a Custom Plugin (code below).
This endpoint retrieves the URI parameters and sends them to wp_signon to sign in.
If wp_signon succeeds in logging in, it returns the user’s data. If not, it returns an error array.
This is the custom endpoint en WP:
`// Register REST API endpoints
class Login_REST_API_Endpoints {
/**
* Register the routes for the objects of the controller.
*/
public static function register_endpoints() {
// endpoints will be registered here
register_rest_route( 'wp', '/login', array(
'methods' => 'GET',
'callback' => array( 'Login_REST_API_Endpoints', 'login' ),
'permission_callback' => '__return_true'
) );
}
/**
* #param WP_REST_Request $request Full data about the request.
* #return WP_Error|WP_REST_Request
*/
public static function login( $request ) {
$data = array();
$data['user_login'] = $request["email"];
$data['user_password'] = $request["password"];
$data['remember'] = true;
$user = wp_signon( $data, false );
if ( !is_wp_error($user) ){
return $user;
} else {
return $error = json_encode(array('error' => true));
}
}
}
add_action( 'rest_api_init', array( 'Login_REST_API_Endpoints', 'register_endpoints' ) );`
So far so good. The problem appears when I activate the SWPM plugin.
I start getting this response (the asterisks are intentional, to hide the real info):
{ "code": "wp_die", "message": "<p>Warning! The Simple Membership plugin cannot process this access request to prevent you from accidentally logging out as WP admin.<\/p><p><a href=\"https:\/\/*********\/wp-admin\/profile.php\" target=\"_blank\">Click here<\/a>to see the profile with which you are logged in in this browser.<\/p><p>In this browser you have connected to the site as an administrator user. First, log out as WP admin and then you will be able to log in as a member.<\/p><p>Alternatively, you can use a different browser (where you are not logged in as an administrator) to test membership access.<\/p><p>Your frequent visitors or members will never see this message. This message is ONLY for the admin user.<\/p>", "data": { "status": 500 }, "additional_errors": [] }
And these are the headers when the error happens (the asterisks are intentional, to hide the real info):
Date: Sat, 11 Feb 2023 02:58:36 GMT Server: Apache Set-Cookie: swpm_session=52883ad4e8ad887e7***************; path=/ X-Robots-Tag: noindex Link: <https://******/wp-json/>; rel="https://api.w.org/" X-Content-Type-Options: nosniff Access-Control-Expose-Headers: X-WP-Total, X-WP-TotalPages, Link Access-Control-Allow-Headers: Authorization, X-WP-Nonce, Content-Disposition, Content-MD5, Content-Type Expires: Wed, 11 Jan 1984 05:00:00 GMT Cache-Control: no-cache, must-revalidate, max-age=0 Content-Length: 890 Connection: close Content-Type: application/json; charset=UTF-8
I already tried:
Close all sessions.
Delete cookies and cache.
Deactivate plugin and activate them one by one.
Test with different browsers.
Try with Insomnia.
And nothing works.
The only thing I have noticed is that when SWPM is disabled, the request is successful (code 200).
Could you please give me some idea of what might be going on and how I could fix it?
In use:
Simple Wordpress Membership 4.2.4. (link)
Wordpress 6.1.1.
New data:
When I GET request from Insomnia, if the SWPM plugin is active, I get a 500 error in the response body. But if it’s inactive, I get the 200 code, user data in the body, and WP login cookies in the header.
Insomnia’s settings say that it automatically stores these cookies and sends them when they are needed.
Now (the interesting thing) if I reactivate the SWPM plugin and do GET, I get code 200, the user data and NEW WP login cookies + SWPM login cookies.
From then on, all the requests you make to WP will be code 200. Logically, in each login request the cookies change.
Now, if I copy these cookies to my fetch code in Node.js, I also get 200 code from WP, even if the SWPM plugin is enabled.
Logically, these cookies expire and it is not something that can be used in production, but this information may help to solve the problem.
I am trying to send the user data (email and password) from Node.js to Wordpress via Rest API (GET) so that the user can log in to Wordpress.
I hope to receive an answer code 200.
I am currently getting response code 500.

Wordpress –– Someone using my admin email address / user name to send emails confirming fictitious registrations

Here is their outging email.
---------- Forwarded message ----------
From: tomnora
To: GcxwtJgnCTWXlhaq
Cc:
Bcc:
Date: Tue, 17 Dec 2019 10:18:39 +0000
Subject: Confirm your subscription to TravlGusto
Hello!
Hurray! You've subscribed to our site.
We need you to activate your subscription to the list(s): My first list by clicking the link below:
Click here to confirm your subscription.
Thank you,
The team!
They get bounced, but why is this happening? How do I stop it?
You cannot. Sending email means saying not only what you want to send and who you want to send it to, but also who you are. And you can say that you're anybody you want:
https://en.wikipedia.org/wiki/Email_spoofing

403:forbidden when reading mails from Exchange online using Microsoft.Graph

I have read emails from Exchange online in c#.net using Office 365 API, but getting some issue on response object
(HttpResponseMessage response = await client.SendAsync(request))
i.e
{StatusCode: 403, ReasonPhrase: 'Forbidden', Version: 1.1, Content:
System.Net.Http.StreamContent, Headers:
{
Transfer-Encoding: chunked
request-id: a0983ea5-313d-4234-b1c6-249f3359c71c
client-request-id: a0983ea5-313d-4234-b1c6-249f3359c71c
x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"SouthEast
Asia","Slice":"SliceB","ScaleUnit":"002","Host":"AGSFE_IN_3","ADSiteName":"SIN"}
}
OutBoundDuration: 906.2963
Duration: 1177.9769
Cache-Control: private
Date: Wed, 23 Dec 2015 12:08:42 GMT
Server: Microsoft-IIS/8.5
X-Powered-By: ASP.NET
Content-Type: application/json
}}
For more information :
Please refer this link : http://dev.office.com/getting- started/office365apis
Provide required information login,app name etc.
Download app and run your system
In run time ,error occurred on response object
So Please tell me how to fixed it and let me know if any information required.
Please help me out.
Thanks,
Sheena
You have to register your application on Azure Active Directory (AAD) and set the application permissions to read emails in your app registration.
Check out this presentations starting fromr slide #24:
http://www.mostafaelzoghbi.com/2015/10/identity-and-office-365-presentation-on.html
Hope this helps.
Exchange mailbox access by API was disabled for that account. Please follow https://msdn.microsoft.com/en-us/library/office/dn467892(v=exchg.150).aspx to enable it, e.g. Set-CASMailbox –Identity adam#contoso.com -EwsEnabled:$true

Wordpress - Contact form 7 email not received

I am unable to receive email in my configured email in contact form 7 (in word press). All of the email finally end up in my default email account with the subject "Mail delivery failed: returning message to sender"
The body of the email is given as under. One thing i noticed is that the 'recepient' is test#test.com, while i configured the To to my own email id. The snapshot of my config is (I changed my own domain name with sample mydomain for security purposes):
The failure email i end up getting in the default email id is:
This message was created automatically by mail delivery software.
A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:
test#test.com
host secureserver.net [85.45.125.0]
SMTP error from remote mail server after RCPT TO:<test#test.com>:
550 5.1.1 <test#test.com> recipient rejected. This is a default recipient used as a placeholder in many web applications. Please check your settings and try again.
------ This is a copy of the message, including all the headers. ------
Return-path: <myname#secureserver.net>
Received: from myname by secureserver.net with local (Exim 4.85)
(envelope-from <myname#secureserver.net>)
id 1Z9pj0-002GGR-NL
for test#test.com; Tue, 30 Jun 2015 00:12:58 -0700
To: test#test.com
Subject: [mydomain! Contact] From hi
X-PHP-Script: www.mydomain.com/index.php for 85.52.214.184
Date: Tue, 30 Jun 2015 07:12:58 +0000
From: hi <test#test.com>
Message-ID: <b325164dd89b7dbe9861fdf0e1f578c1###str_replacement_1##>
X-Priority: 3
X-Mailer: PHPMailer 5.2.7 (https://github.com/PHPMailer/PHPMailer/)
Reply-To: hi#gmail.com
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Name: hi
Email: hi#gmail.com
Comments: hi hihihi
Sending and receving emails with CF7 works very well for most people. Anyone who has problems should check server configurations and take a look at Contact Form 7 Email Issues.

ASP Classic CDOSYS

We are having issues sending an XML file via email using CDOSYS. The problem (we suspect) is too many headers on the outgoing email.
Our old emailer (SMTP Mailer) had the following setting "UseMSMailHeaders" set to false which resulted in minimal headers on the outgoing mail. We are looking to add this same setting to the CDOSYS to achieve the same minimal headers - however there is no such configuration setting for CDOSYS.
The working email headers (created using SMTP Mailer) were as follows:
X-mailer: Asp Component Bundle 4.03 (COMB63E607)
Content-Type: text/xml; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
The email headers (created using CDOSYS) are now:
X-Originating-IP: [82.11.130.88]
X-Spam: 0
X-Authority: v=2.1 cv=Rs1LLUWK c=1 sm=1 tr=0 a=NcIbe7jg/PruPBS/SkG5Ow==:117
a=NcIbe7jg/PruPBS/SkG5Ow==:17 a=OZ8DCac85m8A:10 a=uObrxnre4hsA:10
a=NLZqzBF-AAAA:8 a=KQ9VrMxVm9wA:10 a=r77TgQKjGQsHNAKrUKIA:9 a=9iDbn-4jx3cA:10
a=cKsnjEOsciEA:10 a=WzHNiX6cKY2DZ1D7HSYA:9 a=SSmOFEACAAAA:8 a=e0m2sKwKAAAA:8
a=LDuhtmgyDqFV3yBKdvUA:9 a=wVYsaH73nbqcsVgb:21 a=p8LqAaNAe91_BBSR:21
a=zJJgJrR4LD4A:10 a=ZHtQ2jxvbGEA:10 a=JiXicNB2fugA:10
X-Priority: 1
X-MSMail-Priority: Normal
thread-index: Ac8vaWtRWKRVMRvtReSO2cdupviJVQ==
Content-Type: multipart/mixed;
boundary="----=_NextPart_000_0009_01CF2F69.6B518590"
X-Mailer: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.1.7601.17609
I notice that the CDOSYS email Content-Type is set to "multipart/mixed" even though our ASP code has the following line:
Set Mailer = CreateObject("CDO.Message")
Mailer.Configuration.Fields.Item (http://schemas.microsoft.com/cdo/configuration/content-type") = "text/xml"
Is this normal behaviour?
Thank you for any help.
What exactly is too many headers? A good mail transport agent (MTA) should provide detailed headers. Maybe what you mean to ask is something along the lines of: I changed how I build and transmit my SMTP messages and now they all bounce. Is something like that happening? If not, try to elaborate on the details of the nature of the true underlying problem further.
As for the second part of your message, if you attach a file, the content type will change automatically.

Resources