Page 1 of 1
[SOLVED] New line in basic e-mail..
Posted: Tue May 01, 2007 5:27 am
by ddj
Hello, what's wrong with the code below? Why I get the body of the e-mail on a single line even if I used the new line char (\n\n) ? Any help would be appreciated... thank you!
Code: Select all
$message = new Swift_Message('Test', 'Hello,\n\nhow are you?');
Posted: Tue May 01, 2007 5:33 am
by jamiel
Don't use literal quotes.
Code: Select all
$message = new Swift_Message('Test', "Hello,\n\nhow are you?");
Posted: Tue May 01, 2007 5:40 am
by ddj
thanks a lot, it works (I spent 3 hours with this stupid thing..)

Posted: Thu May 10, 2007 9:32 am
by chazter6
Am I missing something?
I am too trying to put blank lines but cant seem to get it working properly. My e-mail looks like this...
(Its one long line...no line breaks)
Here are your login details. Your password has been reset. Please change your TEMPORARY password once you have logged into the LNP system. Login: loginInfo Password: passwordInfo
I want it to look like this, with linebreaks for Login and Password info.
Here are your login details. Your password has been reset. Please change your TEMPORARY password once you have logged into the LNP system.
Login: loginInfo
Password: passwordInfo
Code: Select all
// SwiftMailer settings
$yourName='Administrator';
$yourEmail='webmaster@idomain.tld;
$subject='Your Temporary password';
$msg='Here are your login details. Your password has been reset. Please change your TEMPORARY password once you have logged into the system.';
$messgeHTML = $msg."\n\n"."Login: ".$details['login']."\n\n"."Password: ".$details['password'];
$subjMsg = $subject;
// Add the recipient
$name=$details['firstName'].' '.$details['lastName'];
$toAddress = $form->getSubmitValue('email');
$swiftHtml = new Swift_Message_Part($messgeHTML, "text/html");
//Start Swift
$swift =& new Swift(new Swift_Connection_SMTP("mail.domain.tld"));
//Create the message
$message =& new Swift_Message($subjMsg);
$message->attach($swiftHtml,"text/html");
// Instantiate a repipient list
$recipients =& new Swift_RecipientList();
$recipients->addTo($toAddress, $name);
//Now check if Swift actually sends it
if ($swift->send($message, new Swift_Address($toAddress, $name), $yourEmail)) {
echo 'success';
} else {
echo 'fail';
}
Thanks for your assistance!
Posted: Thu May 10, 2007 10:52 am
by dillion
\n\n is only good for plain text emails and in your case you are using HTML. So I would replace all instances of
with
Posted: Thu May 10, 2007 11:28 am
by chazter6
dillion,
thanks for the response. You are absolutely correct. For some reason, I thought my e-mail client settings were set to TEXT, but I guess they were set to HTML instead. I should have thought of that.
Cheers!