I'm trying to put a heart symbol ♥ into the headline of an email which should be sent via the php pear mail package.
But the receiver gets a ? instead of the heart so there has to be some mistake. It works if I manually send the email with my mail client.
My code is the following:
require_once "Mail.php";
$smtp = Mail::factory('smtp',
array ('host' => 'host',
'port' => port,
'auth' => true,
'username' => 'username',
'password' => 'password');
$headers = array ('From' => 'sender',
'Subject' => '♥ test',
'Charset' => 'utf-8',
);
$mail = $smtp->send($to, $headers, 'heart test');
What do I need to change in order to make the heart display correctly for the receiver of the email?
You're not specifying the character set properly, so yes... it is a charset mismatch:
$headers = array(
'Content-type' => 'text/plain; charset=UTF-8'
);
is what you should have. There is no Charset header.
Related
I struck on this problem on many days. Please help. I have followed the cakephp documentation. but could not resolve issue.
Could not send email: unknown
Error: An Internal Error Has Occurred.
Following is Configuration emai.php
<?php
class EmailConfig {
public $default = array(
'transport' => 'Mail',
'from' => 'developer.support#sevenrocks.in',
'charset' => 'utf-8',
'headerCharset' => 'utf-8',
);
public $smtp = array(
'transport' => 'Smtp',
'from' => array('site#localhost' => 'SevenRocks'),
'host' => 'ssl://smtp.sevenrocks.in',
'port' => 465,
'timeout' => 30,
'username' => 'developer.support#sevenrocks.in',
'password' => 'developerofsevenrocks',
'client' => null,
'log' => true,
'charset' => 'utf-8',
//'headerCharset' => 'utf-8',
);
}
Following is code in controller
$email = new CakeEmail();
$email->emailFormat('html');
$email->from(array($from_email => SITE_NAME));
$email->to($to);
$email->subject($subject);
if ($files)
{
$email->attachments($files);
}
if ( !$email->send($content) )
{
return false;
}
First: to debug CakePHP 2x applications search for debug in your app/Config/core.php and change it to Configure::write('debug', 2); to see the full error message.
Second: Some providers may prevent you from sending Mails via PHP directly (default mail config). A better solution may to use the smtp configuration you provided in email.php.
To use your smtp configuration change your controller code to:
$email = new CakeEmail('smtp');
$email->emailFormat('html');
$email->to($to);
$email->subject($subject);
For more Info see https://book.cakephp.org/2.0/en/core-utility-libraries/email.html#configuration
I am trying to use send grid as an email platform for my php but the problem is I cannot send multiple emails as a CC header and also I cannot edit the FROM header to display a Name in front of the email address.
$from = "News Letter <new#gmail.com>" // cannot get the "News Letter" to Display
$cc = array("aaaaaa#gmail.com","bbbbb#gmail.com");// doesnt send to arrays
$params = array(
'api_user' => $user,
'api_key' => $pass,
'to' => $to,
'cc' => $cc,
'subject' => $subject,
'html' => $body,
'from' => $headers
);
You need to use some additional fields in your $params array, like so:
$params = array(
'api_user' => $user,
'api_key' => $pass,
'to' => $to,
'toname' => 'Newsletter Person',
'cc' => $cc,
'subject' => $subject,
'html' => $body,
'from' => $headers,
'fromname' => 'Newsletter'
);
Sendind directly via the Mail.Send endpoint does not allow for an array in the CC field, however if you use the SendGrid PHP library then you can use and array for CC
I'm trying to send emails that will bounce to an address specified by me, different from the address it's sent from.
the code i'm using to send the emails is
$headers = array (
'From' => $emailAdr
'To' => $emailDest,
'Subject' => $subject,
);
$hdrs = $mime->headers($headers);
$smtp = Mail::factory('smtp',
array ('host' => 'ssl://'.$emailServer,
'auth' => true,
'port' => '465',
'username' => $emailUser,
'password' => $emailPass));
$mail = $smtp->send($emailDest, $hdrs, $body);
I searched all over the internet for a solution to this.
Try this:
$headers = array (
'From' => $emailAdr
'To' => $emailDest,
'Subject' => $subject,
'Return-path' => 'return#path.com',
);
But, different mail servers translate return path by their own rules (it's just will use From, Reply-to or X-Return-Path etc
hi friends how to send a email through kohana 3.0
i tried but not working
my code is like this
$subject = ' : Message to Leet Street';
$from = array('Clarence', 'ratnaraju.java#gmail.com');
email::send('ratnaraju.bonam#gmail.com', $from , $subject, 'hi how r u Brother ');
url::redirect();
config file is:
return array
(
'default' => array(
'transport' => 'smtp',
'options' => array
(
'hostname' => 'smtp.gmail.com',
'username' => 'ratnaraju.bonam#gmail.com',
'password' => 'Ratna',
'port' => '465',
),
)
);
thanks in advance
Use this module to send email:
https://github.com/shadowhand/email
it needs this vendor in the vendor-dir:
https://github.com/swiftmailer/swiftmailer
I want to write a simple Drupal7 module, which contains following codes, used to send mail. Don't ask me to use Phpmailer or others. Could you help? Thanks very much!
<?php
include('Mail.php');
$recipients = array( 'someone#example.com' ); # Can be one or more emails
$headers = array (
'From' => 'someone#example.com',
'To' => join(', ', $recipients),
'Subject' => 'Testing email from project web',
);
$body = "This was sent via php from project web!\n";
$mail_object =& Mail::factory('smtp',
array(
'host' => 'prwebmail',
'auth' => true,
'username' => 'YOUR_PROJECT_NAME',
'password' => 'PASSWORD', # As set on your project's config page
#'debug' => true, # uncomment to enable debugging
));
$mail_object->send($recipients, $headers, $body);