On line email form hangs on php mail() function. What server issue could be causing this? - web-hosting

I have a contact form on my website that has a dead simple php mail() function. I am 99% certain the php is not the issue as I have the exact same function on other sites that works fine.
However, when I try to use the form on one site in particular it seems to hang and not send the email and not redirect to the success page. Would anyone know what could be causing this on the server side?
If anyones interested my php is:
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$company = $_REQUEST['company'] ;
$phone = $_REQUEST['phone'] ;
$message= $_REQUEST['message'] ;
$webmaster_email = "myemail#mysite.com";
$thankyou_page = "http://www.mysite.com/thanks-for-your-inquiry.html";
mail( "$webmaster_email", "Site Form", "From: noreply#mysite.com",
"From: $email \n
Name: $name \n
Phone: $phone\n
Message: $message\n ");
header( "Location: $thankyou_page" );

Related

Perl - Outlook - Including an embedded image into body of email (HTML)

I need to include an image into body of email (using HTML formatting) so it's embedded, not as an extra attachement using library Win32::OLE in Perl invoking the Outlook client installed on Windows.
Below code works, but received email does not display the image. I can see the only a small square symbol indicating the inline embedded image is missing or is corrupted .
#use strict;
use warnings;
use Win32::OLE;
#get new Outlook instance
my $mail = new Win32::OLE('Outlook.Application');
die "Unable to start Outlook instance: $!" if !defined $mail;
my $item = $mail->CreateItem(0);
die "Unable to create mail item: $!" if !defined $item;
$item->{'To'} = 'mypersonalgmailaddress#gmail.com';
$item->{'CC'} = '';
$item->{'Subject'} = 'Test for embedded/inline image';
$item->{'BodyFormat'} = 'olFormatHTML';
$item->{'HTMLBody'} = "<html><body><img src=\"signature.png\"></body></html>";
$item->save();
#attach an image and make it embedded.
my $attachments = $item->Attachments();
$attachments->Add('C:\signature.png', olEmbeddeditem);
#send it
$item->Send();
my $error = Win32::OLE->LastError();
print STDERR "Win32::OLE error: $error" if $error;
Does anybody know what is wrong with the above code? Any advices are highly appreciated.
You need to attach an image and then set a CID which you can use in the message body:
Attachment attachment = newMail.Attachments.Add(#"E:\Pictures\image001.jpg"
, OlAttachmentType.olEmbeddeditem , null , "Some image display name" );
string imageCid = "image001.jpg#123";
attachment.PropertyAccessor.SetProperty(
"http://schemas.microsoft.com/mapi/proptag/0x3712001E", imageCid);
newMail.HTMLBody = String.Format("<body><img src=\"cid:{0}\"></body>", imageCid );

How to decrypt cookie?

I've just caught a crash reported on sentry, I am trying to debug and see the root cause for the problem.
Luckily, in the cookies panel, I can see the laravel_session value that was used while crash happened.
The question, is, how can decrypt the cookie?
You can decrypt the cookie with the following code:
$cookie = 'eyJpdiI6ImFUQ0FvMWFSVlNvTmhlQjdLWGw1Z1E9PSIsInZhbHVlIjoicFh6Q09iTDl0K0huWU1Nc1NYVmxSY2hPRGU5Vk85dDJyYUpRbUVjRWg5R0JxYkVobkF3YkZVcVQrakFFUmxaVnZrTjFST3F3RTZ4akpDZEpvUFJiQXc9PSIsIm1hYyI6IjlhYmJhMTY3MWMxYWI3YjJmNmFjMmNkZWE0MWZmMmVhNTNiMjI5ZWY3NzUwNzQ0ZjAzMGQ1ZGU0YzVhNjJmZGYifQ==';
$cookie_contents = json_decode( base64_decode( $cookie, true ));
$value = base64_decode( $cookie_contents->value );
$iv = base64_decode( $cookie_contents->iv );
$clear = unserialize( \openssl_decrypt($value, \Config::get( 'app.cipher' ), \Config::get( 'app.key' ), OPENSSL_RAW_DATA, $iv));
echo "Cookie contents (Session ID): $clear\n";
You should end up with a session ID that looks something like this:
Laravel 5.1: 55782b00dbfcc3f848585ac2cefc66802d773cf5
Laravel 5.4: yPjeV74joY4MtMNNtTpeOYBP2CMixJBBChc9HRND
I didn't test with Laravel 5.3, but I'm confident it will work.
When using this code, make sure you paste the entire contents of the cookie into the $cookie variable, including the two equals signs at the end.
For laravel 6 I think it's pretty much the same
$base64_key = "base64:ISAcSPwQ0HDqqLygaS9LyPzs5ZujMAKOjBou+gyz9sw=";
$payload = json_decode(base64_decode($_COOKIE["your_cookie_name"]), true);
$iv = base64_decode($payload['iv']);
$key = base64_decode(substr($base64_key, 7));
$sessionId = openssl_decrypt($payload['value'], 'AES-256-CBC', $key, 0, $iv);
echo "Session Id: $sessionId";
But check few things:
Cipher encoding, mine is 'AES-256-CBC', it can be 'AES-128-CBC' if your key length is 16
Key format, mine start with "base64:" so I have to remove this part first

special character in message are encoded when it's delivered

I'm using Laravel-4-Nexmo package to send sms but the message is encoded on delivery .
$receiverNumber = "xxxxxxxxxxx"
$message = "hi from nexmo ? ";
$options = array( 'status-report-req' => 1 );
$Nexmo = Nexmo::sendSMS('me', $receiverNumber , $message , $options);
and received message looks like this :
hi+from+nexmo+%3F+
I would like to receive as
hi from nexmo ?
I look forward to see what could be the solution
Probably the mentioned package does not encode the given message so you should use urlencode($yourString) before using the pacckage
I do not know what was wrong with my code above, and I decided to use similar package and it works now. you can find the package here https://github.com/Artistan/nexmo

Subject in PHPmail $head gets doubled and in wrong encoding

Im using IPN to send mail to customers after a purchase. Everythings going well except one small annoying thing. When I test to buy a product with my mail as buyer the mail in my mail inbox looks like this: http://snag.gy/grrMy.jpg <- it has double subject after itself and the first one not changed into UTF-8 - why is this? And if I click on that mail suddenly only the UTF-8 coded subject will show (as intended) like this: http://snag.gy/k5VyF.jpg
Here is the PHP code that I use:
$to = filter_var($ipn_post_data[payer_email], FILTER_SANITIZE_EMAIL);
$date = date('Y-m-d');
$subject = "Tack för Ert köp! / Thank you for your order!";
$headerFields = array(
'Date: ' . date('r', $_SERVER['REQUEST_TIME']),
"Subject: =?UTF-8?Q?".imap_8bit($subject)."?=",
"From: {$to}",
"MIME-Version: 1.0",
"Content-Type: text/html;charset=utf-8"
);
mail($to, $subject, $message, implode("\r\n", $headerFields));
So the only "problem" really is that whn inbox the mails subject gets doubled with the first one with wrong encoding and it looks bad. Anyone that has input on this?
You pass $subject to mail() twice -- once in the second argument, and once in the fourth as part of $headerFields.
Try passing null as the second argument instead.

Codeigniter's XML-RPC shows no response data

I'm attempting to connect to an XML RPC server with no luck, I am getting an empty response with no debugging information whatsoever. I've switched on set_debug(), but still nothing.
Can anyone tell me why I am getting no response from the server, no error information and no debug information?
$this->load->library('xmlrpc');
$this->xmlrpc->set_debug(TRUE);
$this->xmlrpc->server('https://myurl.com/xmlrpc', 80);
$this->xmlrpc->method('login');
$request = array('param1', 'param2');
$this->xmlrpc->request($request);
echo 'Error: '. $this->xmlrpc->display_error() . '<br/>';
echo 'Response: '. print_r($this->xmlrpc->display_response(), true) . '<br/>';
Even if you type https:// in server method you are still connecting with server via http, look at 2nd parameter - the port you have set is 80.
Just in case.
I forgot to use:
$this->xmlrpc->send_request()
its best used in a conditional statement like:
if ( ! $this->xmlrpc->send_request())
{
echo $this->xmlrpc->display_error();
}
else
{
echo '<pre>';
print_r($this->xmlrpc->display_response());
echo '</pre>';
}

Resources