|
direct use of my_mail() function vs mailqueue
|
|
02-17-2012, 07:06 PM
Post: #1
|
|||
|
|||
|
direct use of my_mail() function vs mailqueue
In one of my plugins I am using the mailqueue to send emails on new posts, however I need to send them with a reply-to header set to the poster email.
One issue is that the send_mail_queue() routine overwrites the Reply-To: header I set in the headers attribute of the mail queue I insert. This occurs in the set_common_headers() function of the mail handler. So that leaves me with using the my_mail function directly as it supports a $return_email parameter. However, I use this function, the message body looses all the new lines and just shows \r\n\ in the message body. I find this odd since I am sending the same $db->escape_string($post['message']); variable to both the my_mail() function as well as inserting it into the mail queue This gives me the correct reply-to, but leaves \r\n as text in the message without any line breaks: PHP Code: my_mail($db->escape_string($notifyuser['email']), this gives me the correct message body with line breaks, but overwrites the reply-to: PHP Code: $new_email = array(I can not see where in the my_mail() process that the message is getting double escaped. Maybe I am just missing the obvious. Can anyone help? CommunityPlugins.com Latest Releases: StopForumSpam v1.5, MyBB Publisher v3.4, MediaWiki Bridge |
|||
|
02-17-2012, 08:20 PM
(This post was last modified: 02-17-2012 08:43 PM by Beardy.)
Post: #2
|
|||
|
|||
|
RE: direct use of my_mail() function vs mailqueue
Would nl2br() not work, to convert the \r\n characters to <br />? Not sure if they'll display as raw-text or HTML inside the email though. E-mail formatting isn't really one of my strong points.
I also looked through the my_mail and send_mail_queue functions and I can't see why the reply-to header isn't getting passed along, but I've never really used MyBB's mail functions so maybe I'm missing something. |
|||
|
02-17-2012, 08:52 PM
Post: #3
|
|||
|
|||
RE: direct use of my_mail() function vs mailqueue
(02-17-2012 08:20 PM)Beardy Wrote: Would nl2br() not work, to convert the \r\n characters to <br />? Not sure if they'll display as raw-text or HTML inside the email though. E-mail formatting isn't really one of my strong points. Since I want to send as plain text, it will just display as <br /> (02-17-2012 08:20 PM)Beardy Wrote: I also looked through the my_mail and send_mail_queue functions and I can't see why the reply-to header isn't getting passed along, but I've never really used MyBB's mail functions so maybe I'm missing something. In the mail handler is a function called set_common_headers() that tests for a $return_email and uses that as the reply to, if that is not provided it uses the mybb setting for email, but it does this AFTER inserting the headers I specify basically overriding the Reply-To I specify. But I can not specify the $return_email value when using the built-in mail queue. CommunityPlugins.com Latest Releases: StopForumSpam v1.5, MyBB Publisher v3.4, MediaWiki Bridge |
|||
|
02-17-2012, 10:02 PM
(This post was last modified: 02-17-2012 10:40 PM by Beardy.)
Post: #4
|
|||
|
|||
|
RE: direct use of my_mail() function vs mailqueue
Try using htmlspecialchars() on the message variable instead of $db->escape_string.
Actually, that'll display some characters weird in the e-mail since it won't be displaying HTML. strip_tags() might be better. I did something like this with strip_tags() and received the e-mail fine: PHP Code: $message = strip_tags("asd
|
|||
|
02-17-2012, 10:08 PM
Post: #5
|
|||
|
|||
|
RE: direct use of my_mail() function vs mailqueue
the weird thing is that I already use mybb's htmlspecialchars_uni on the message and it works fine when going through the mail queue.
there is something different about how send_mail_queue() processes the message as compared to a direct use of my_mail, which send_mail_queue uses as well. CommunityPlugins.com Latest Releases: StopForumSpam v1.5, MyBB Publisher v3.4, MediaWiki Bridge |
|||
|
02-17-2012, 10:24 PM
Post: #6
|
|||
|
|||
|
RE: direct use of my_mail() function vs mailqueue
$db->escape_string() probably shouldn't be used when you don't actually put it into a database.
Apart from that you have a space missing before < in the from address. Other than that I don't see anything out of the ordinary, but I didn't test it myself. Maybe you should add a debug in the my_mail function directly and log the exact parameters its called with and see if you can find a difference this way Google SEO | Gravatar | Hooks | HTMLPurifier | Overview | Patches | PluginLibrary @ GitHub/frostschutz |
|||
|
02-17-2012, 11:31 PM
Post: #7
|
|||
|
|||
RE: direct use of my_mail() function vs mailqueue
(02-17-2012 10:24 PM)frostschutz Wrote: $db->escape_string() probably shouldn't be used when you don't actually put it into a database. maybe the $db->escape_string is causing it. I just want it to be safe if the post message has html in it. i guess the htmlspecialchars handles that though. i will try it again CommunityPlugins.com Latest Releases: StopForumSpam v1.5, MyBB Publisher v3.4, MediaWiki Bridge |
|||
|
02-18-2012, 12:13 AM
(This post was last modified: 02-18-2012 12:15 AM by Beardy.)
Post: #8
|
|||
|
|||
RE: direct use of my_mail() function vs mailqueue
(02-17-2012 11:31 PM)pavemen Wrote: maybe the $db->escape_string is causing it. I just want it to be safe if the post message has html in it. i guess the htmlspecialchars handles that though. If you don't mind using the my_mail function directly after a post has been created (instead of trying to find a solution for the send_mail_queue() problem), my earlier post should work for you. htmlspecialchars() will display certain characters (<, >, etc) in HTML ASCII, and since the e-mail is being sent as plain-text they won't be displayed properly. Using strip_tags() will only remove HTML tags (<a></a>, <br />, <hr />, etc) and won't affect single characters. |
|||
|
02-25-2012, 06:04 AM
Post: #9
|
|||
|
|||
|
RE: direct use of my_mail() function vs mailqueue
i think you want to send email with some headers and <br /> or \n to create new line.
i needed in my email and i did it as following: $admin_email_message = 'this is test <br /> and you must see a new line in your email.'; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; my_mail($from, $admin_email_subject, $admin_email_message , $from , '' ,$headers); now my email is showing in html mode and <br /> is working fine With Regards and many thanks. ------------------------------------------ |
|||
|
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)
Search
Member List
Calendar
Help




