I would like to know how can I remove the auto line break in email. I am using the phpmailer function:
$from = 'dass#gmail.com';
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= "From: ".$from."\r\n";
$headers .= "Reply-To: admin#gmail.com \r\n";
$returnPath = "-r".$from;
mail($to, $subject, $msgbody, $headers, $returnPath)
Here is a running example:
jsfiddle.net/qwyh0551/
Replace this code:
<td>What ki
nd
By this code:
<td>What kind
And your problem is gone. The french fries link does work in the fiddle, so I assume you already fixed that.
Related
I want to convert the link to the button in PHP mail.php file.
$message = sprintf($this->language->get('mail_message'), $store_name, $link);
I will appreciate if someone helps me to convert the link to the button.
To achieve this, you have to send html email instead of plain/text email. It is pretty simple, leave the images on the server and send the PHP + CSS to them...
$to = 'xyz#example.com';
$subject = 'Subject';
$headers = "From: " . strip_tags($_POST['req-email']) . "\r\n";
$headers .= "Reply-To: ". strip_tags($_POST['req-email']) . "\r\n";
$headers .= "CC: abc#example.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
$message = '<p>Anchor Text</p>';
mail($to, $subject, $message, $headers);
I know there are a few similar questions to this but I just can't get it working.
Ok, I have a list of emails grabbed from my database in a variable called $emailList.
I can get my code to send an email from a form if I put the variable in the $to section but
I cannot get it to work with bcc. I've even added an email to the $to incase it was that but it doesn't make a difference.
Here is my code.
$to = "name#mydomain.com";
$subject .= "".$emailSubject."";
$headers .= 'Bcc: $emailList';
$headers = "From: no-reply#thepartyfinder.co.uk\r\n" . "X-Mailer: php";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = '<html><body>';
$message .= 'THE MESSAGE FROM THE FORM';
if (mail($to, $subject, $message, $headers)) {
$sent = "Your email was sent!";
} else {
$sent = ("Error sending email.");
}
I've tried both codes:
$headers .= 'Bcc: $emailList';
and
$headers .= 'Bcc: '.$emailList.';
It's not that the emails aren't separated because they are. I know they are because it works if I put $emailList in the $to section.
I Should add, ignore the $message bits and the HTML stuff. I've not provided all of that so that is why it's missing from this code.
You have $headers .= '...'; followed by $headers = '...';; the second line is overwriting the first.
Just put the $headers .= "Bcc: $emailList\r\n"; say after the Content-type line and it should be fine.
On a side note, the To is generally required; mail servers might mark your message as spam otherwise.
$headers = "From: no-reply#thepartyfinder.co.uk\r\n" .
"X-Mailer: php\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers .= "Bcc: $emailList\r\n";
You were setting BCC but then overwriting the variable with the FROM
$to = "name#mydomain.com";
$subject .= "".$emailSubject."";
$headers .= "Bcc: ".$emailList."\r\n";
$headers .= "From: no-reply#thepartyfinder.co.uk\r\n" .
"X-Mailer: php";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = '<html><body>';
$message .= 'THE MESSAGE FROM THE FORM';
if (mail($to, $subject, $message, $headers)) {
$sent = "Your email was sent!";
} else {
$sent = ("Error sending email.");
}
The one email From:support#lead.com works fine. But when changed to john.doe#lead.com it doesn't work? See below.
Both are valid email addresses (fictitious for this example) in the domain from which they are sent.
I have the question into Netfirms support too. I expect to move to phpmailer or API to a ESP (e.g., mailchimp) account soon, but this is just bugging me that the little change breaks the email function.
Code:
Works:
$headers = "Mime-Version: 1.0\n";
$headers .= "Content-Type: text/html;charset=UTF-8\n";
$headers .= 'From: support#lead.com' . "\r\n";
$headers .= 'Bcc: bcc#lead.com' . "\r\n";
// $headers .= 'Return-Path: bcc#lead.com' . "\r\n";
mb_internal_encoding("UTF-8");
if (!mail($to, $subject, $body, $headers, "-f bcc#mylead.com")) echo ("Message delivery failed");
Doesn't Work: (only changed support to john.doe):
$headers = "Mime-Version: 1.0\n";
$headers .= "Content-Type: text/html;charset=UTF-8\n";
$headers .= 'From: john.doe#lead.com' . "\r\n";
// $headers .= 'Return-Path: bcc#lead.com' . "\r\n";
mb_internal_encoding("UTF-8");
if (!mail($to, $subject, $body, $headers, "-f bcc#lead.com")) echo ("Message delivery failed");
Don't know how this really should matter, but you're mixing \n and \r\n in the headers, which may confuse your mail server... Would you mind to try this out?
function sendEmail($address,$subject,$message)
{
$headers = "Reply-To: miloAds Team <admin#miloads.com>\r";
$headers .= "Return-Path: miloAds Team <admin#miloads.com>\r";
$headers .= "From: miloAds Team <admin#miloads.com>\r";
$headers .= "Organization: Milonas Media LLC\r";
$headers .= "MIME-Version: 1.0\r";
$headers .= "Content-type: text/plain; charset=iso-8859-1\r";
$headers .= "X-Priority: 3\r";
$headers .= "X-Mailer: PHP". phpversion() ."\r";
mail($address, $subject, $message, $headers);
}
When sending out an email, the header is appearing in the body.
Try changing each of the \r escapes to \r\n and see if that helps.
Quoth the PHP manual:
additional_headers (optional)
String to be inserted at the end of the email header.
This is typically used to add extra headers (From, Cc, and Bcc).
Multiple extra headers should be separated with a CRLF (\r\n).
Make sure to not include the trailing \r\n on the last header either.
Also make sure to strip any newlines from the $subject as that could cause problems. See if those help.
Add \n to \r, i.e. \r\n and remove the last one:
function sendEmail($address,$subject,$message)
{
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "From: miloAds Team <admin#miloads.com>\r\n";
$headers .= "Reply-To: miloAds Team <admin#miloads.com>\r\n";
$headers .= "Organization: Milonas Media LLC\r\n";
$headers .= "X-Priority: 3\r\n";
$headers .= "X-Mailer: PHP". phpversion();
mail($address, $subject, $message, $headers);
}
In my mail client or gmail the sender is always apache#hosting12
Any way to fix this issue?
I have tried setting the headers like these with no success. Can sombody please help me?
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= "From: <'$from'> \r\n";
$headers .= "Reply-To: <'$from'> \r\n";
$headers .= "Return-Path: <'$from'>\r\n";
$headers .= "X-Mailer: PHP \r\n";
or
$headers = "From: $from";
I found that answer on a french forum.
http://www.developpez.net/forums/d413965/php/outils/configuration-sendmail_path-sender/
You can add a 5th param to the mail function:
mail($mail_recipient, $subject, $message, $headers, '-f'.$mail_from);
Ths '-f' + mail_from force the system to send the email as the mail_from.
There are extra single quotes in your header. Try like this:
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= "From: <$from> \r\n";
$headers .= "Reply-To: <$from> \r\n";
$headers .= "Return-Path: <$from>\r\n";
$headers .= "X-Mailer: PHP \r\n";
Also you can remove the unnecessary "Reply-To" and "Return-Path".
Please remove single quotation mark from around $from and use {$from}
$headers .= 'From: Birthday Reminder <birthday#example.com>' . "\r\n";
or you can use following signatures to pass from
mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )
EDIT:
You also want to check sendmail_from setting in php.ini file.